You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "jtuglu1 (via GitHub)" <gi...@apache.org> on 2026/05/21 01:52:04 UTC

[PR] fix: fix chat handler response parsing (druid)

jtuglu1 opened a new pull request, #19495:
URL: https://github.com/apache/druid/pull/19495

   <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. -->
   
   <!-- If you are a committer, follow the PR action item checklist for committers:
   https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. -->
   
   ### Description
   
   Overlord task report requests can sometimes be too eager during ingestion and ping a task before the http server servicing the chat requests has spun up. This causes 4xx/5xx to be returned, which are not correctly parsed by the chat client.
   
   Example:
   
   
   ```
   2026-05-21T01:33:43,097 WARN [qtp1790748582-95] org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask - Encountered exception when getting live subtask report for task: task123
   java.util.concurrent.ExecutionException: java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class org.apache.druid.indexer.report.TaskReport]: missing type id property 'type'
    at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 10] (through reference chain: org.apache.druid.indexer.report.TaskReport$ReportMap["error"])
   	at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:592) ~[guava-32.1.3-jre.jar:?]
   	at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:571) ~[guava-32.1.3-jre.jar:?]
   	at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91) ~[guava-32.1.3-jre.jar:?]
   	at org.apache.druid.common.guava.FutureUtils.get(FutureUtils.java:52) ~[druid-processing-34.0.0.jar:34.0.0]
   	at org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask.getTaskReport(ParallelIndexSupervisorTask.java:1881) ~[druid-indexing-service-34.0.0.jar:34.0.0]
   	at org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask.getRowStatsAndUnparseableEventsForRunningTasks(ParallelIndexSupervisorTask.java:1711) ~[druid-indexing-service-34.0.0.jar:34.0.0]
   	at org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask.doGetRowStatsAndUnparseableEventsParallelMultiPhase(ParallelIndexSupervisorTask.java:1688) ~[druid-indexing-service-34.0.0.jar:34.0.0]
   	at org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask.doGetRowStatsAndUnparseableEvents(ParallelIndexSupervisorTask.java:1795) ~[druid-indexing-service-34.0.0.jar:34.0.0]
   	at org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask.doGetLiveReports(ParallelIndexSupervisorTask.java:1838) ~[druid-indexing-service-34.0.0.jar:34.0.0]
   	at org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask.getLiveReports(ParallelIndexSupervisorTask.java:1868) ~[druid-indexing-service-34.0.0.jar:34.0.0]
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
   	at java.base/java.lang.reflect.Method.invoke(Method.java:569) ~[?:?]
   	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:137) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) ~[jersey-servlet-1.19.4.jar:1.19.4]
   	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) ~[jersey-servlet-1.19.4.jar:1.19.4]
   	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) ~[jersey-servlet-1.19.4.jar:1.19.4]
   	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0]
   	at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:290) ~[guice-servlet-5.1.0.jar:?]
   	at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:280) ~[guice-servlet-5.1.0.jar:?]
   	at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:184) ~[guice-servlet-5.1.0.jar:?]
   	at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:89) ~[guice-servlet-5.1.0.jar:?]
   	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85) ~[guice-servlet-5.1.0.jar:?]
   	at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121) ~[guice-servlet-5.1.0.jar:?]
   	at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133) ~[guice-servlet-5.1.0.jar:?]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.apache.druid.server.security.PreResponseAuthorizationCheckFilter.doFilter(PreResponseAuthorizationCheckFilter.java:84) ~[druid-server-34.0.0.jar:34.0.0]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.apache.druid.server.initialization.jetty.StandardResponseHeaderFilterHolder$StandardResponseHeaderFilter.doFilter(StandardResponseHeaderFilterHolder.java:164) ~[druid-server-34.0.0.jar:34.0.0]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.apache.druid.server.initialization.jetty.ResponseHeaderFilterHolder$ResponseHeaderFilter.doFilter(ResponseHeaderFilterHolder.java:100) ~[druid-server-34.0.0.jar:34.0.0]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.apache.druid.server.security.AllowHttpMethodsResourceFilter.doFilter(AllowHttpMethodsResourceFilter.java:78) ~[druid-server-34.0.0.jar:34.0.0]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.apache.druid.server.security.AllowOptionsResourceFilter.doFilter(AllowOptionsResourceFilter.java:74) ~[druid-server-34.0.0.jar:34.0.0]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at com.netflix.druid.security.NetflixAuthenticator$NetflixAuthenticationFilter.doFilter(NetflixAuthenticator.java:188) ~[?:?]
   	at org.apache.druid.server.security.AuthenticationWrappingFilter.doFilter(AuthenticationWrappingFilter.java:59) ~[druid-server-34.0.0.jar:34.0.0]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.apache.druid.server.security.SecuritySanityCheckFilter.doFilter(SecuritySanityCheckFilter.java:77) ~[druid-server-34.0.0.jar:34.0.0]
   	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505) ~[jetty-servlet-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:772) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:59) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:181) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487) ~[jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732) [jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479) [jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) [jetty-server-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [jetty-io-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [jetty-io-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:555) [jetty-io-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:410) [jetty-io-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:164) [jetty-io-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [jetty-io-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [jetty-io-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) [jetty-util-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) [jetty-util-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) [jetty-util-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [jetty-util-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409) [jetty-util-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) [jetty-util-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) [jetty-util-9.4.57.v20241219.jar:9.4.57.v20241219]
   	at java.base/java.lang.Thread.run(Thread.java:840) [?:?]
   ```
   
   <!--
   In each section, please describe design decisions made, including:
    - Choice of algorithms
    - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources?
    - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns)
    - Method organization and design (how the logic is split between methods, parameters and return types)
    - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
   -->
   
   
   <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
   
   <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. -->
   
   <!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
   
   #### Release note
   <!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users. 
   
   If your change doesn't have end user impact, you can skip this section.
   
   For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes).
   
   -->
   
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `MyFoo`
    * `OurBar`
    * `TheirBaz`
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] fix: fix chat handler response parsing (druid)

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #19495:
URL: https://github.com/apache/druid/pull/19495#discussion_r3278256207


##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskRunnerUtilsTest.java:
##########
@@ -52,4 +66,84 @@
     );
     Assert.assertEquals("https://1.2.3.4:8290/druid/worker/v1/task/foo%20bar%26/log", url.toString());
   }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationOk() throws Exception
+  {
+    final HttpClient httpClient = EasyMock.createMock(HttpClient.class);
+    final String report = "my report";
+    EasyMock.expect(httpClient.go(EasyMock.anyObject(Request.class), EasyMock.anyObject(InputStreamFullResponseHandler.class)))
+            .andReturn(Futures.immediateFuture(response(HttpResponseStatus.OK, report)));
+    EasyMock.replay(httpClient);
+
+    final Optional<InputStream> stream = TaskRunnerUtils.streamTaskReportsFromTaskLocation(
+        httpClient,
+        new URL("http://example.com/liveReports")
+    );
+
+    Assert.assertTrue(stream.isPresent());
+    Assert.assertEquals(report, StringUtils.fromUtf8(ByteStreams.toByteArray(stream.get())));
+    EasyMock.verify(httpClient);
+  }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationNotFound() throws Exception
+  {
+    assertStreamTaskReportsFromTaskLocationUnavailable(HttpResponseStatus.NOT_FOUND);
+  }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationServiceUnavailable() throws Exception
+  {
+    assertStreamTaskReportsFromTaskLocationUnavailable(HttpResponseStatus.SERVICE_UNAVAILABLE);
+  }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationUnexpectedStatus() throws Exception
+  {
+    final HttpClient httpClient = EasyMock.createMock(HttpClient.class);
+    EasyMock.expect(httpClient.go(EasyMock.anyObject(Request.class), EasyMock.anyObject(InputStreamFullResponseHandler.class)))
+            .andReturn(Futures.immediateFuture(response(HttpResponseStatus.INTERNAL_SERVER_ERROR, "error")));
+    EasyMock.replay(httpClient);
+
+    final IOException e = Assert.assertThrows(
+        IOException.class,
+        () -> TaskRunnerUtils.streamTaskReportsFromTaskLocation(
+            httpClient,
+            new URL("http://example.com/liveReports")

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [URL.URL](1) should be avoided because it has been deprecated.
   
   [Show more details](https://github.com/apache/druid/security/code-scanning/11246)



##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskRunnerUtilsTest.java:
##########
@@ -52,4 +66,84 @@
     );
     Assert.assertEquals("https://1.2.3.4:8290/druid/worker/v1/task/foo%20bar%26/log", url.toString());
   }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationOk() throws Exception
+  {
+    final HttpClient httpClient = EasyMock.createMock(HttpClient.class);
+    final String report = "my report";
+    EasyMock.expect(httpClient.go(EasyMock.anyObject(Request.class), EasyMock.anyObject(InputStreamFullResponseHandler.class)))
+            .andReturn(Futures.immediateFuture(response(HttpResponseStatus.OK, report)));
+    EasyMock.replay(httpClient);
+
+    final Optional<InputStream> stream = TaskRunnerUtils.streamTaskReportsFromTaskLocation(
+        httpClient,
+        new URL("http://example.com/liveReports")

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [URL.URL](1) should be avoided because it has been deprecated.
   
   [Show more details](https://github.com/apache/druid/security/code-scanning/11245)



##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskRunnerUtilsTest.java:
##########
@@ -52,4 +66,84 @@
     );
     Assert.assertEquals("https://1.2.3.4:8290/druid/worker/v1/task/foo%20bar%26/log", url.toString());
   }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationOk() throws Exception
+  {
+    final HttpClient httpClient = EasyMock.createMock(HttpClient.class);
+    final String report = "my report";
+    EasyMock.expect(httpClient.go(EasyMock.anyObject(Request.class), EasyMock.anyObject(InputStreamFullResponseHandler.class)))
+            .andReturn(Futures.immediateFuture(response(HttpResponseStatus.OK, report)));
+    EasyMock.replay(httpClient);
+
+    final Optional<InputStream> stream = TaskRunnerUtils.streamTaskReportsFromTaskLocation(
+        httpClient,
+        new URL("http://example.com/liveReports")
+    );
+
+    Assert.assertTrue(stream.isPresent());
+    Assert.assertEquals(report, StringUtils.fromUtf8(ByteStreams.toByteArray(stream.get())));
+    EasyMock.verify(httpClient);
+  }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationNotFound() throws Exception
+  {
+    assertStreamTaskReportsFromTaskLocationUnavailable(HttpResponseStatus.NOT_FOUND);
+  }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationServiceUnavailable() throws Exception
+  {
+    assertStreamTaskReportsFromTaskLocationUnavailable(HttpResponseStatus.SERVICE_UNAVAILABLE);
+  }
+
+  @Test
+  public void testStreamTaskReportsFromTaskLocationUnexpectedStatus() throws Exception
+  {
+    final HttpClient httpClient = EasyMock.createMock(HttpClient.class);
+    EasyMock.expect(httpClient.go(EasyMock.anyObject(Request.class), EasyMock.anyObject(InputStreamFullResponseHandler.class)))
+            .andReturn(Futures.immediateFuture(response(HttpResponseStatus.INTERNAL_SERVER_ERROR, "error")));
+    EasyMock.replay(httpClient);
+
+    final IOException e = Assert.assertThrows(
+        IOException.class,
+        () -> TaskRunnerUtils.streamTaskReportsFromTaskLocation(
+            httpClient,
+            new URL("http://example.com/liveReports")
+        )
+    );
+
+    Assert.assertTrue(e.getMessage().contains("500 Internal Server Error"));
+    EasyMock.verify(httpClient);
+  }
+
+  private static void assertStreamTaskReportsFromTaskLocationUnavailable(
+      final HttpResponseStatus status
+  ) throws Exception
+  {
+    final HttpClient httpClient = EasyMock.createMock(HttpClient.class);
+    EasyMock.expect(httpClient.go(EasyMock.anyObject(Request.class), EasyMock.anyObject(InputStreamFullResponseHandler.class)))
+            .andReturn(Futures.immediateFuture(response(status, "error")));
+    EasyMock.replay(httpClient);
+
+    Assert.assertEquals(
+        Optional.absent(),
+        TaskRunnerUtils.streamTaskReportsFromTaskLocation(httpClient, new URL("http://example.com/liveReports"))

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [URL.URL](1) should be avoided because it has been deprecated.
   
   [Show more details](https://github.com/apache/druid/security/code-scanning/11247)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] fix: fix chat handler response parsing (druid)

Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm merged PR #19495:
URL: https://github.com/apache/druid/pull/19495


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org