Skip to content

Conversation

raphael
Copy link
Member

@raphael raphael commented Sep 30, 2025

Summary

  • Remove dead locals (id, eventType, retry) in generated SSE client processEvent; fields are written directly on the event struct.
  • Fix struct event decoding: decode directly into the struct pointer to avoid pointer-to-pointer issues; keep primitive parsing via partial_sse_parse.
  • Leave retry header unassigned client-side pending typed conversion (server still emits retry as per SSE spec).

Repro

  • In a downstream repo (e.g., aura), design defines SSE endpoints with SSEEventID/SSEEventType mapped to fields on the StreamingResult/Result.
  • goa gen then go test ./gen/... failed with compiler errors in generated http/front/client/sse.go: unused id/eventType locals.

Root cause

  • client_sse.go.tpl declared local variables for id/eventType/retry but set event fields directly; locals were unused.
  • Additionally, when the event type is a struct and no DataField is specified, the template initialized event as a pointer but used a parse partial that decodes into &event, resulting in a pointer-to-pointer decode target.

Fix

  • Remove unused local declarations.
  • For struct events without DataField, decode JSON into the struct pointer (event) directly; primitives keep using the parse partial.

Validation

  • goa unit tests pass locally.
  • Regenerating the downstream repo with replace goa.design/goa/v3 => /Users/raphael/src/goa eliminates the compile errors in generated SSE HTTP client code.

Notes

  • Retry parsing remains untyped on the client path; if you want typed retry propagation into user event structs we can add a field-type-aware parse in a follow-up. This change avoids the previous incorrect string assignment into numeric fields while keeping server-side retry output unchanged.

- Remove dead locals (id, eventType, retry) in client SSE processEvent; fields are set directly on event.
- Decode struct events directly into the struct pointer to avoid pointer-to-pointer (Decode(&event)).
- Preserve primitive parsing via existing partial_sse_parse.
- Retry header is not assigned client-side pending typed conversion; server continues to emit retry as per SSE spec.

This fixes compile errors in generated SSE clients (unused vars) and ensures correct JSON decoding for struct events.
@raphael raphael enabled auto-merge (squash) September 30, 2025 23:54
@raphael raphael merged commit cd3ed8a into v3 Sep 30, 2025
7 checks passed
@raphael raphael deleted the http-codegen/fix-sse-client branch September 30, 2025 23:56
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