Skip to content

Goa v3.36.0

Latest

Choose a tag to compare

@raphael raphael released this 24 Nov 03:38
· 1 commit to v3 since this release
9ca14aa

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 selected nil object or collection branches that previously passed silently.
  • Cascaded result views on collection attributes (#4079): Declaring View(...) on an ArrayOf, MapOf, or named collection attribute inside a ResultType view 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 OneOf union references and body role bindings across HTTP request, response, OneOf error, multipart, WebSocket, and gRPC generation.
  • Transitive Extend and Reference inheritance (#4075, #4076): Resolves References and Bases in dependency order before finalizing child attributes, preserving validations and recursive ResultType view projections without prematurely resolving unfinalized Extend bases during Reference.
  • 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 context in 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 warms proxy.golang.org and sum.golang.org automatically when publishing tags (#4069).

Dependencies

  • Updated google.golang.org/grpc to v1.85.0, golang.org/x/net to v0.63.0, golang.org/x/tools to v0.53.0, golang.org/x/mod to v0.43.0, golang.org/x/sync to v0.25.0, golang.org/x/sys to v0.50.0, golang.org/x/text to v0.44.0, and go.yaml.in/yaml/v3 to v3.0.6 across goa, examples, and plugins (#4089).

Upgrade Notes

  1. Runtime-only security upgrade (FormatHostname): Existing generated HTTP, gRPC, and JSON-RPC services pick up the GHSA-hpx2-h3qx-xjh9 fix by running go get goa.design/goa/v3@v3.36.0 and rebuilding—no goa gen regeneration is required. Verify that callers do not pass underscores, trailing dots, ports, bare digits, or IPv4 addresses to Format(FormatHostname) fields (use FormatIP or FormatURI / FormatURIReference when IP addresses or URIs are intended).
  2. Full generator upgrade:
    go get goa.design/goa/v3@v3.36.0
    go install goa.design/goa/v3/cmd/goa@v3.36.0
    goa gen <module>/design
    Update goa.design/plugins/v3 to v3.36.0 in the same change when used.
  3. Design and peer checks when regenerating: Move any transport-only or mismatched HTTP Param, Header, or Cookie Default on object payloads onto the mapped Payload attribute (#4086); ensure tests constructing required or pointer OneOf values select a valid non-nil branch (#4070); and deploy regenerated clients and servers together if an existing ResultType view sets a non-default View(...) 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!