Skip to content

feat(#1612): generated wire-model validation foundation, with ACM as the pilot - #1683

Merged
scttfrdmn merged 4 commits into
mainfrom
feat/v0133-wire-model
Nov 24, 2026
Merged

scttfrdmn merged 4 commits into
mainfrom
feat/v0133-wire-model

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Part of #1612. This PR ships the generated validation foundation and turns it on for ACM. Still to come under #1612: the SESv2, ElastiCache, Route 53 and EC2 key-pair and placement-group pilots, in feat/v0133-wire-validation-pilots, which is based on this branch. The shared pagination primitive is W-P's PR. Generated serializers are #1681.

  • Model snapshot. cmd/gen-wire-model -fetch downloads botocore 1.44.10 (botocoreTag) from GitHub as one tarball. For each mapped service it takes the newest API version, prunes it to the shapes reachable from emulator.RoutedOperations (inputs, outputs and errors) plus paginators, strips the documentation, and writes emulator/wiremodel/<svc>.json.gz and a manifest.json. The result is 70 models, 1,116 operations and about 356 KB gzipped.
    • Coverage. pluginModels (cmd/gen-wire-model/plugins.go) maps all 68 plugins. Two are listed as unmodelled with a reason: execute-api and opensearch. TestPluginModels_CoverEveryRoutedPlugin asserts the mapping covers every plugin.
    • Gaps. Two routed operations are absent upstream: appsync ExecuteGraphQL and servicequotas ListRequestedServiceQuotaChangesByService. Ten more are defined by two of a plugin's models (ELB classic and v2; Timestream), so they are left out of the tables.
    • Refresh hygiene. -fetch removes a model that the previous manifest vendored and the new one no longer lists, and the Scheduler generator refuses a model the manifest does not list.
    • Ordered JSON. The snapshot is re-encoded with a small codec that keeps key order, because member order is the order failures are reported in.
  • Tables. make wire-model generates emulator/wire_model_gen.go (about 0.9 MB, under cfn_schema_gen.go's 1.2 MB).
    • It holds data, not per-field code: one slice of 5,932 shapes, each with its kind, its Min/Max as written in the model, an enum index, a pattern index and its constrained members (with their location, locationName, queryName and flattened traits).
    • wireOperations maps each plugin and operation to its input shape, plus the HTTP method and URI template for REST. wireModels carries each model's metadata.protocols.
    • A member is kept only if it is required or leads to a constraint.
    • make wire-model-check runs offline in CI's Service Reference Drift job, and fails naming any routed operation the snapshot lacks. make wire-model-fetch needs the network and is run by hand.
  • Scheduler model. cmd/gen-scheduler-query-model reads the vendored snapshot instead of the AWS CLI, and gains make scheduler-query-model-check in CI.
    • Its table is byte-identical to what the old generator produces from the AWS CLI 2.42.1 models. I checked by running the old generator against them. Only the two header lines naming the source change.
    • The committed file was stale: it lacked DescribeNetworkInterfaces (examples: Terraform end-to-end journey against substrate #1519), which the regenerated file now includes.
  • Interpreter (emulator/wire_validate.go). validateRequest walks the input shape through one inputView interface, with four adapters:
    • JSON body, and CBOR, decoded with the existing cborDecode and read through the same view.
    • Query and EC2 req.Params: member.N, flattened and named lists, entry.N.key/value, and EC2's queryName or capitalized locationName. The iam/sts/sqs/sns re-encoding at server.go's step 1 replaces req.Body but leaves Params in place, which is what the gate reads.
    • REST: URI labels from matching the model's requestUri (including greedy {Key+}), query-string scalars and repeated-key lists, headers, prefixed header sets, structure and blob payloads, and JSON or XML bodies.
    • What is checked. Required members, length (strings in characters, blobs in bytes, lists, maps) and range, compared exactly with big.Rat. Enum and pattern checks run only where a service opts in. A pattern Go's RE2 cannot compile (botocore patterns are Java regexes, for example (?!-)) is skipped.
    • Adapter choice. The adapter is chosen by the request's wire format (a Smithy-Protocol header, a target or a JSON content type, otherwise form parameters) among the model's metadata.protocols. CloudWatch, which serves CBOR, JSON and Query, is read in each.
    • What is skipped. A body that will not parse is left to the plugin. So is a value of the wrong kind for its shape, such as a string where a list belongs, and a request in a format the model does not list, such as SQS's Query form. A request is read as Query only when it names an Action or carries a form body. A float sent as NaN, Infinity or -Infinity is treated as a float.
    • Patterns compile once, on first use.
  • Errors (emulator/wire_validate_errors.go). validatedServices gives each service its codes and statuses for a missing member and for every other failure, its message style, and its enum and pattern opt-ins.
    • The message format is AWS's front-end validator's: N validation error(s) detected: …; …, Value null at 'x' … Member must not be null, and paths like tags.2.member.key. A list of scalars is reported once, as Member must satisfy constraint: [...]. Each form is cited next to the literal.
    • No function answering ValidationException cites a common-errors page.
    • I kept scheduler_errors.go's helpers separate. They render one hard-coded message per guard, and Scheduler is not validated yet.
  • Gate. stepValidate (step 4.6) is the last step of prePluginGates.check, after authorization, quota, consistency and fault injection. It covers only top-level requests to services in validatedServices. Internal dispatches go through RouteRequest and never reach it.
    • Opt-out: wire.validate: false / SUBSTRATE_WIRE_VALIDATE=false (Config.Wire.SkipValidation, so the zero Config validates) and WithoutWireValidation().
    • A validation refusal is counted in substrate_requests_total and substrate_request_errors_total, under the service's code.
    • Every existing precedence and replay-pipeline test passes unchanged.
    • New tests pin that authorization and an armed fault both come before validation.
  • Replay versioning. Event.ValidationModel (validation_model, omitempty) records botocore/1.44.10 whenever the gate ran live.
    • Recording. WithValidationModel records it regardless of include_state_hashes. SQLite and file backends store the serialized event, so no schema change is needed. Fixture export embeds the field, which a test asserts.
    • Replay. A replay runs the gate only for events that carry the field and are not internal dispatches, using the binary's own snapshot even when the recorded version differs. The concept page documents this.
    • Older recordings, and recordings made with the gate off, replay unchanged. A test replays a gate-off recording into a validating server and finds zero differences.
  • ACM pilot. ACM answers ValidationException/400 for every failure. Enum and pattern checks are on.
    • The message form Value of the input at (and Value null at for missing members) comes from observed AWS answers, cited in the table. The reference publishes no text. The release notes need a ## Provenance entry for this.
    • Kept, and aligned rather than removed: the RequestCertificate DomainName check and the CertificateArn constraint checks. The gate makes them unreachable for a client's request, but three paths still reach them without it: a CloudFormation dispatch, a Scheduler universal target (acm is in schedulerSDKServices) and any request with validation off. They now call wireCheckMember, which runs the gate's own view, walk and refusal over that one member, so their answers match the gate's byte for byte: every failure for the member, lengths counted in characters, and an empty value treated as present. TestWireValidation_ThePluginsOwnChecksAnswerInTheGatesWords and TestWireValidation_WithItOffThePluginStillRefuses byte-compare the cases: missing, empty, too short, too long with non-ASCII characters, within the length in characters but over it in bytes, and failing only the pattern. The tagging resolver keeps its own wording through acmValidateCertificateARN.
    • Raw-HTTP tests cover: a missing member, an explicit null, an over-length string, out-of-range numbers, a nested list-element path, a list length, a pattern, an enum, a list-of-scalars failure and several failures in one message. They also check that a valid session returns byte-identical bodies with validation on and off, and that a CloudFormation dispatch is not validated.
  • Docs. New docs/reference/concepts/validation.md covers what is checked, the message forms, gate order, opt-out and replay. Also updated: the ACM reference page, the testing guide (a Request Validation section and the replay step table), and docs/contributing.md (CI table and the plugin-checklist row).

Routed-operation catalog unchanged.

Gates run locally:

  • make lint test e2e;
  • operation-catalog-check docs-reference-check docs-headings-check operation-docs-check authz-reference-check cfn-schema-check wire-model-check scheduler-query-model-check doc-links-check;
  • wire-bookkeeping-check discarded-unmarshal-check discarded-marshal-check discarded-state-check nondeterminism-check comment-history-check;
  • docs-versions docs-counts-check;
  • SUBSTRATE_IAC=1 make iac-e2e: Terraform and CDK journeys pass;
  • the VitePress build.

Follow-up issues (milestone v0.137.0, label area: wire):

@scttfrdmn scttfrdmn added this to the v0.133.0 milestone Nov 24, 2026
@scttfrdmn scttfrdmn added type: feature New feature or improvement area: wire Generated wire layer: service models, request validation, serializers labels Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

…the pilot

Vendors botocore 1.44.10's models pruned to the routed operations under
emulator/wiremodel, generates constraint tables into wire_model_gen.go, and adds a
validation gate (step 4.6, after authorization and fault injection) that checks a
client request's required members, lengths and ranges, plus enums and patterns per
service. ACM is validated. Events record the snapshot the gate ran against, and a
replay runs the gate only for events that carry it.
…s the gate does not see

A stack's dispatch, a schedule's universal target and the tagging resolver reach ACM
without the gate, so the DomainName and CertificateArn checks stay and render through
the shared validation form instead of being deleted.
…ol selection, pattern cache

- A validation refusal is counted in substrate_requests_total and request_errors_total.
- A value of the wrong kind for its shape stops validation and leaves the plugin to answer.
- The adapter is chosen by the request's wire format among metadata.protocols, which the
  tables now carry, so CloudWatch is read in Query and JSON as well as CBOR.
- Model patterns compile once; a flattened XML list is named by its member.
- -fetch removes models the new manifest drops; the Scheduler generator refuses a model the
  manifest does not list.
- Tests pin that ACM's own checks refuse with validation off.
…ncoded; NaN floats

- wireCheckMember runs the gate's own view and walk over one member, so ACM's CertificateArn
  and DomainName checks answer byte for byte what the gate does (all failures, lengths in
  characters, an empty value as present). The tagging resolver keeps its own wording.
- A request is read as Query only when it names an Action or carries a form body.
- A float sent as NaN, Infinity or -Infinity is a float.
- -fetch removes only models the previous manifest vendored.
@scttfrdmn
scttfrdmn merged commit 62fc10a into main Nov 24, 2026
20 checks passed
@scttfrdmn
scttfrdmn deleted the feat/v0133-wire-model branch November 24, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: wire Generated wire layer: service models, request validation, serializers type: feature New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant