chore(java): use IR discriminatorContext for SSE event-level discrimination#12495
Closed
tstanmay13 wants to merge 2 commits intomainfrom
Closed
chore(java): use IR discriminatorContext for SSE event-level discrimination#12495tstanmay13 wants to merge 2 commits intomainfrom
tstanmay13 wants to merge 2 commits intomainfrom
Conversation
…nation Co-Authored-By: tanmay.singh@buildwithfern.com <tstanmay13@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: tanmay.singh@buildwithfern.com <tstanmay13@gmail.com>
Contributor
|
This PR is stale because it has been open 25 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Contributor
|
This PR was closed because it has been inactive for 5 days after being marked stale. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs #12242
Refactors the Java SDK generator's SSE event-level discrimination logic to use the IR's
discriminatorContextfield (added in PR #12242) instead of the manual heuristic that checked if a discriminator property name matched SSE envelope fields (event,id,retry,data).Link to Devin run: https://app.devin.ai/sessions/76958a26d45348e6ab03ffbbc7647ad2
Requested by: @tstanmay13
Changes Made
AbstractGeneratorCli: ExtractsdiscriminatorContextfrom raw IR JSON before Jackson deserialization (the irV63 Java model doesn't expose this field, but it's present in the JSON). NewIrLoadResultwrapper,loadIr()replacesgetIr(), andextractDiscriminatorContexts()walks the JSON tree for union types.AbstractGeneratorContext/ClientGeneratorContext: New constructor overload and getter to threadMap<TypeId, String> discriminatorContextsthrough the context hierarchy.Cli: All 3ClientGeneratorContextconstruction sites passgetDiscriminatorContexts().SseDiscriminationAnalyzer: Core change — replacesSSE_ENVELOPE_FIELDS.contains(...)with a lookup into the discriminator contexts map."protocol"→ event-level,"data"or absent → data-level.resolveUnionTypenow returnsUnionResolutionResult(TypeId + union) instead of just the union declaration.AbstractHttpResponseParserGenerator: Updated caller to pass discriminator contexts.versions.yml: New 3.36.2 entry.Testing
./gradlew compileJava)./gradlew spotlessCheck)Human Review Checklist
extractDiscriminatorContextsmanually walks the IR JSON tree. This is necessary because the Java IR model (v63) doesn't exposediscriminatorContext. Verify the JSON path (types -> {id} -> shape -> discriminatorContext) matches the actual IR structure.event/id/retry/datawas treated as event-level. Now only types explicitly markeddiscriminatorContext: "protocol"in the IR get event-level treatment. IfdiscriminatorContextis absent, it defaults to"data". Confirm this is the intended semantic for older IRs that predate the field.SseEventParser.javaunchanged: The resource template still has its ownSSE_ENVELOPE_FIELDSfor runtime parsing — this is intentional (separate concern from build-time analysis).