You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for named JSON server-sent events (SSE) in Azure-v1 data-plane convenience APIs.,> ,> tsp,> @events,> union Events {,> message: string,,> ,> @terminalEvent,> completed: string,,> },> ,> op stream(): SSEStream<Events>;,>
Curious why this is opt-in rather than just enabled?
Since we already had SSE customization code for Search GA Java SDK, my initial gut feeling is that we don't do major emitter changes before Search GA release.
Though current generated code is almost identical without customization, guess I could remove this opt-in once this PR's mature.
This accepts named events without checking event.payloadContentType, including string payloads explicitly marked @contentType("text/plain") (supported by packages/events/lib/decorators.tsp:41). Their unquoted SSE data is then passed to JsonProviders.createReader by SseEventConverterTemplate.java:146, so valid streams fail decoding; reject non-JSON payload content types through the existing unsupported-stream diagnostic and retain the raw APIs.
Generate stream callbacks from wire types before client conversion
Calling getClientType() before generating the JSON callback discards wire encodings: a seconds-encoded duration maps to Duration and is decoded with Duration.parse(...) rather than reading the numeric seconds (PrimitiveMapper.java:113–126, ClassType.java:466), so valid payloads fail during iteration, including inside collections. Generate callbacks from the mapped wire type and then convert the decoded value to its client type, as StreamSerializationModelTemplate.java:1564–1599 does.
Calling getClientType() before building the JSON callback discards wire encodings: for example, a seconds-encoded duration becomes Duration and generates Duration.parse(reader.getString()), which fails on a valid numeric SSE payload such as 42. Deserialize using the wire type and then apply its client conversion (as WireTypeClientTypeConverter.java:105–120 does), recursively for collection elements, or retain the raw API for these encodings.
Transport SSE definitions by union CID and bind canonical references before Java mapping. Emit only mapped definitions, preserve named output, and generate direct unnamed payloads or typed mixed and primitive-literal wrappers with strict matching and inclusive termination.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The SSE changes can remove ARM/Fluent methods and reference ungenerated event types, while helper-import and payload-name collisions cause generated Java clients to fail compilation.
Generate typed SSE models through schema-local metadata and the ordinary model, mapper, package, and module workflow while keeping CodeModel passive and admission scoped to actual consuming clients.
Preserve binary fallback for unsupported streams and target fallback diagnostics at authored operations so operation and service suppression work under warning-as-error.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14ecbaeb-e976-401b-b4ef-40d8cbcd7bd3
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Automatic typed SSE activation changes public convenience return types, while deferred generated-name/import collision handling requires human review of compatibility boundaries before rollout.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
SSE changes cross public API and streaming lifecycle contracts, requiring human review of ownership, cancellation, and deferred naming risks plus generated-client and end-to-end transport validation beyond available static checks.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Public streaming return-type and lifecycle changes need maintainer review and generated-client validation, particularly because generated-name and import collision handling remains deferred.
The remaining naming collisions are acknowledged and deferred from this PR. Resolving their review threads records that scope decision; it does not mean all colliding inputs now generate compilable Java.
The table summarizes the recorded investigation, not a newly executed collision matrix. Rarity is a qualitative estimate from the required naming combinations, not measured frequency. Rows are ordered by rarity category; ties are not ranked.
Case
Scenario
Possible collision names
Outcome
Estimated rarity
Stream container / request DTO
A request model shares a stream container's name, conflicting with stream return/error-path references in the same client, including across different operations.
Flux, CloseableIterableStream
Compile failure
Uncommon: requires a matching model name in the affected SSE client.
JDK date / payload DTO
A payload model shares the JDK date type's name and is combined with plainDate decoding, producing ambiguous references in the base envelope or serializer, including nested collections.
LocalDate
Compile failure
Uncommon: requires both the date-named model and date decoding in the affected source.
Runtime helper / request DTO
A request model shares an SSE runtime helper's simple name, producing conflicting client imports and calls.
ServerSentEventStreamHelper
Compile failure
Rare: requires an exact helper/model name match.
Serializer / request DTO
A request model matches a generated per-stream serializer name, producing conflicting client imports and calls.
Stream-derived serializer names, e.g. SomeEventSerializer
Compile failure
Rare: requires an exact stream-derived serializer/request name match.
Serializer / payload DTO
A payload model matches its generated serializer; for example, the payload of SomeEvents is named like that stream's serializer.
SomeEventSerializer
Compile failure
Rare: requires a payload to match its stream-derived serializer name.
Names exempt from deduplication
In Azure-branded generation, TypeSpec namespaces starting with Azure. skip automatic name deduplication. An ordinary model and an SSE envelope retain the same name, which the mapper rejects.
Ordinary SkippedEvent and the generated base envelope for SkippedEvents
Generation failure
Rare: requires both an exempt namespace and matching ordinary/envelope names.
"Exempt from deduplication" means names are not automatically given distinct suffixes, not that those models are excluded from generation.
The same deferred scope includes the cross-package event/request and event/payload clashes raised in the review (TestStreamEvent, AzureCollisionEvent), whether an existing mapper guard rejects a particular input before rendering or conflicting simple-name imports would otherwise prevent compilation. This table is not exhaustive. A general solution would need to reconcile complete client and model import sets, nested helper names, and qualified references—not just allocate distinct synthetic schema names.
In the recorded cases, conflicting inputs failed during generation or generated-Java compilation; none was observed to pass both stages with incorrect bindings or silently fall back to binary. Noncolliding, ordinary-deduplication, and normalized-name controls passed with the intended bindings. Those observations are not guarantees for untested inputs.
Addressed separately: commit 07568108fb908675f60d3d1c0e543d4efc1d0eba renamed the per-stream nested ConstructorAccessor to SseEventConstructorAccessor. Focused generated-compilation and decoding regressions cover the original ConstructorAccessor payload and independent stream registration. This is a bounded fix, not a general uniqueness guarantee; matching the new nested name remains a potential collision.
Previously working input regressions, incorrect bindings that survive compilation, silent naming-triggered binary fallback, and broken deduplication controls remain actionable defects rather than being dismissed by this deferral.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Automatically replacing existing convenience return types while deferring naming and import collisions requires a maintainer’s compatibility and scope review.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Generated public return-type changes and SSE stream cleanup contracts require maintainer validation against real sync/async transports and generated clients, which could not be exercised in this dependency-free review environment.
No open issues 🎉
Review effort: Balanced
This branch has not been deployed
No deployments
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
emitter:client:javaIssue for the Java client emitter: @typespec/http-client-java
3 participants
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.
Flux<Event>and syncCloseableIterableStream<Event>APIs with typed event wrappers.@dataextraction.