Repository navigation
Goa v3.36.0 hardens Format(FormatHostname) validation against RFC 1123 and RFC 3696 (GHSA-hpx2-h3qx-xjh9), adds RFC 3986 Format(FormatURIReference) validation for URIs and relative references, catches mismatched HTTP parameter/header/cookie defaults at generation time, exposes formatted generated files in memory (generator.Sources and generator.CompleteSources), documents shared HTTP error status codes in OpenAPI, and fixes union branch validation, cascaded collection result views, recursive unions, WebSocket error codecs, and gRPC stream/collection generation.
Security Fix
Strict RFC 1123 and RFC 3696 Internet hostname validation (GHSA-hpx2-h3qx-xjh9, #4090). Previously, goa.ValidateFormat(..., goa.FormatHostname) matched values against ^[[:alnum:]][[:alnum:]\-]{0,61}[[:alnum:]]|[[:alpha:]]$. Because | has lower precedence than ^ and $, any string starting with two alphanumeric characters or ending with an ASCII letter passed validation—including strings containing whitespace, CR/LF control characters, slashes, queries, or .. sequences. ValidateFormat now checks FormatHostname values with a single-pass ASCII byte scanner enforcing RFC 1123 section 2.1 (1 to 253 ASCII bytes of dot-separated 1 to 63-byte LDH labels, with no empty labels or trailing root dot) and RFC 3696 section 2 (the rightmost label cannot be all-numeric). Existing generated HTTP, gRPC, and JSON-RPC services pick up this fix immediately by upgrading goa.design/goa/v3 to v3.36.0 without re-running goa gen. Thanks to @arpitjain099 for reporting this issue.
Highlights
RFC 3986 FormatURIReference validation (#4082). String attributes can now declare Format(FormatURIReference) ("uri-reference") to accept both full URIs ("https://example.com/a?b=c") and relative references ("/users/123", "../a", "?q=1", "#frag"). Generated validators check the RFC 3986 grammar directly—including scheme syntax, percent-encoded triplets, IPv6/IPvFuture literals, and colon-free first relative path segments—and OpenAPI v2 and v3 documents emit "format": "uri-reference". Because "" is a valid same-document reference under RFC 3986, pair Format(FormatURIReference) with MinLength(1) when empty strings should be rejected.
Compile-time checks for HTTP mapping defaults (#4086). Generated HTTP server decoders and CLI flags read field defaults on object payloads from the payload attribute, whereas OpenAPI schemas also inspect defaults declared inside HTTP Param, Header, and Cookie blocks. goa gen now rejects transport-only or mismatched HTTP defaults on object payloads with a diagnostic naming both the HTTP wire element and the payload attribute, preventing OpenAPI from advertising defaults that runtime decoding would ignore.
Complete OpenAPI documentation for shared HTTP error status codes (#4083). When multiple errors on an endpoint map to the same HTTP status code, OpenAPI 3.0 and 3.2 specifications now preserve every error description, combine distinct error body schemas with anyOf, and key examples by error name instead of letting the last declared error overwrite earlier ones. Swagger 2.0 documents list all error descriptions, merge headers, and pair the first body schema with its matching example so output stays valid under Swagger 2.0 validators.
In-memory generated source APIs (codegen/generator, #4074, #4077). Tooling and sandboxed runners can call generator.Sources to obtain formatted generated Go, .proto, and OpenAPI files in memory without writing to disk, or generator.CompleteSources when publishing generated trees from sandboxes (CompleteSources fails fast before rendering if any planned file requires SkipExist or a filesystem finalizer such as protoc).
Fixes
- Union branch selection validation (#4070): Generated union validators and HTTP / JSON-RPC union-body decoders now call
Validate()on the union before checking branch fields—including when branches declare no field constraints—rejecting uninitialized required/pointer unions, unknown discriminators, and selectednilobject or collection branches that previously passed silently. - Cascaded result views on collection attributes (#4079): Declaring
View(...)on anArrayOf,MapOf, or named collection attribute inside aResultTypeview now propagates that view through nested element projections and view validators instead of falling back to"default". - Recursive unions across HTTP and gRPC (#4084): Preserves recursive
OneOfunion references and body role bindings across HTTP request, response,OneOferror, multipart, WebSocket, and gRPC generation. - Transitive
ExtendandReferenceinheritance (#4075, #4076): ResolvesReferencesandBasesin dependency order before finalizing child attributes, preserving validations and recursiveResultTypeview projections without prematurely resolving unfinalizedExtendbases duringReference. - gRPC collections and stream envelopes (#4071, #4072): Preserves nullable named object elements inside gRPC collections (#4071) and reuses top-level wrapper messages when referenced inside gRPC stream envelopes so generated code compiles cleanly (#4072).
- WebSocket error encoder imports and test reliability (#4073, #4080, #4088, #4069): Imports
contextin HTTP server codecs for services whose only endpoints with mapped HTTP errors use WebSockets (#4073), binds X-Ray test UDP listeners on OS-assigned ports (#4080), aligns companion repository Go versions during release (#4088), and warmsproxy.golang.organdsum.golang.orgautomatically when publishing tags (#4069).
Dependencies
- Updated
google.golang.org/grpctov1.85.0,golang.org/x/nettov0.63.0,golang.org/x/toolstov0.53.0,golang.org/x/modtov0.43.0,golang.org/x/synctov0.25.0,golang.org/x/systov0.50.0,golang.org/x/texttov0.44.0, andgo.yaml.in/yaml/v3tov3.0.6acrossgoa,examples, andplugins(#4089).
Upgrade Notes
- Runtime-only security upgrade (
FormatHostname): Existing generated HTTP, gRPC, and JSON-RPC services pick up theGHSA-hpx2-h3qx-xjh9fix by runninggo get goa.design/goa/v3@v3.36.0and rebuilding—nogoa genregeneration is required. Verify that callers do not pass underscores, trailing dots, ports, bare digits, or IPv4 addresses toFormat(FormatHostname)fields (useFormatIPorFormatURI/FormatURIReferencewhen IP addresses or URIs are intended). - Full generator upgrade:
Update
go get goa.design/goa/v3@v3.36.0 go install goa.design/goa/v3/cmd/goa@v3.36.0 goa gen <module>/design
goa.design/plugins/v3tov3.36.0in the same change when used. - Design and peer checks when regenerating: Move any transport-only or mismatched HTTP
Param,Header, orCookieDefaulton object payloads onto the mappedPayloadattribute (#4086); ensure tests constructing required or pointerOneOfvalues select a valid non-nil branch (#4070); and deploy regenerated clients and servers together if an existingResultTypeview sets a non-defaultView(...)on a collection attribute whose element fields differ from"default"(#4079). See the v3.36.0 upgrade guide for complete details and rollback guidance.
Contributors
Thank you to everyone who contributed to Goa v3.36.0: @RanKKI, @tchssk, @xeger, @uberbrodt, @zak-blake, @arpitjain099, and @raphael!