Skip to content

fix: Java extractor — preserve URL path when streaming endpoints call .newBuilder() twice - #6

Merged
gavinsharp merged 1 commit into
mainfrom
gavinsharp/fix-streaming-extract
May 12, 2026
Merged

fix: Java extractor — preserve URL path when streaming endpoints call .newBuilder() twice#6
gavinsharp merged 1 commit into
mainfrom
gavinsharp/fix-streaming-extract

Conversation

@gavinsharp

@gavinsharp gavinsharp commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Java endpoint parser was silently dropping streaming endpoints (e.g. POST /agent/stream-chat) from code-examples.json because it reset pathSegments = [] on every .newBuilder() call.
  • Streaming methods invoke .newBuilder() a second time on the OkHttpClient (client.newBuilder().callTimeout(...).build()), which wiped the URL path captured earlier from HttpUrl.parse(...).newBuilder().addPathSegments(...).
  • Fix is a one-line guard: only enter URL-collection mode when pathSegments is empty. Adds a synthetic java-stream fixture + test pinning the invariant.

Test plan

  • bun test extract-code-examples — 53/53 pass, including the new streaming-endpoint case.
  • Re-ran the extractor against PhenoML/phenoml-java-sdk PR #137: coverage went from 69/70 to 70/71 endpoints, and POST /agent/stream-chat now appears in the manifest with the correct path, request body, response body, and sdkCallSource.

🤖 Generated with Claude Code


Note

Low Risk
Low risk: a small guard in the Java endpoint parser changes when URL-path collection starts, plus a new fixture/test to prevent regressions; main impact is potentially adding previously-missed endpoints to generated manifests.

Overview
Fixes the Java endpoint extractor to not reset/overwrite captured URL path segments when a method calls .newBuilder() multiple times (common in streaming endpoints that also do client.newBuilder() for timeouts).

Adds a focused java-stream fixture and test asserting that POST /agent/stream-chat is still discovered and mapped correctly even with a later OkHttpClient.newBuilder() call.

Reviewed by Cursor Bugbot for commit 4b84de8. Bugbot is set up for automated code reviews on this repo. Configure here.

…wBuilder() twice

Streaming endpoints invoke `.newBuilder()` twice per method — once on
HttpUrl for the path, again on OkHttpClient to configure a custom call
timeout. The parser reset `pathSegments = []` on every `.newBuilder()`,
wiping the path captured earlier and silently dropping the endpoint.
Now only the first `.newBuilder()` is treated as the URL builder.

Adds a java-stream fixture + test mirroring the real streamChat pattern.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@gavinsharp
gavinsharp marked this pull request as ready for review May 12, 2026 13:05
@gavinsharp
gavinsharp merged commit 620b5cf into main May 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant