Repository navigation
Conversation
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 1 changed, 0 removedBuild ID: f9aba8c187564ae9716c6384 URL: https://www.apollographql.com/docs/deploy-preview/f9aba8c187564ae9716c6384
|
6fb33e8 to
b9d4a1a
Compare
71fd6b0 to
bbafdac
Compare
0c12fec to
704b543
Compare
704b543 to
db79bc1
Compare
db79bc1 to
5288714
Compare
5288714 to
42188c8
Compare
f6c1082 to
c8855c0
Compare
The instrumentation, events, spans, instruments, condition, conditional and extendable types each have an inherent validate method. It checks that selectors run at a stage where they can produce a value, and the telemetry plugin logs any problem as a warning. Once these types implement apollo-configuration's Validate trait, the configuration attribute's generated code calls validate with an error collector, and method resolution would pick the inherent method instead. Renaming the inherent methods to validate_selectors keeps the two apart. Behavior is unchanged. Part of ROUTER-2143.
The events, spans and instruments sections and their attribute, selector and value types now use the configuration attribute, so the telemetry instrumentation field no longer needs skip_validate. The header masking RedactMode enum that several selectors use converts too. Fields that serde treated as required, such as each selector's key in its untagged enum, stay required so a selector still has to name what it selects. Three groups of types keep hand-written Validate impls: - The attribute doesn't support generic types. Extendable, Conditional, Condition, SelectorOrValue, StandardEventConfig, the custom event, and the instrument and instrument value types keep their serde and schemars derives and forward validation to their nested sections. - The router, supergraph and subgraph selectors hold a JsonPathInst, which has no Debug impl for the macro's derive, nor a Validate impl. Their other fields are scalars without rules, so their impls are empty. - AttributeValue's F64 variant wraps a plain f64, which has no Validate impl, so the attribute can't derive one for that variant. No variant has a rule to check, so its impl is empty. Every selector's `static` and `default` fields and SelectorOrValue's constant value use it. Custom events and the conditional form of the standard request, response and error events accepted unknown keys. Both now reject them. The schema otherwise gains only null default annotations. Part of ROUTER-2143.
Custom events and the conditional form of the standard request, response and error events now reject unknown keys. No project config file, doc example or migration puts extra keys there, and the configuration usage metrics read only known keys from them. The unknown-key table test gains a case for each, and the changeset and the v3 upgrade guide name them next to the batch processor blocks. Part of ROUTER-2143.
c8855c0 to
1812616
Compare
Telemetry's
instrumentationconfiguration (events, spans and instruments, with their attributes, selectors and conditions) is now declared with apollo-configuration's#[configuration]attribute or has an explicitValidateimpl. The telemetry plugin's lastskip_validatefield is gone, so validation reaches every part of the telemetry configuration while the file is parsed.This is the third and final PR for ROUTER-2143, which converts telemetry's
exporters,apolloandinstrumentationsubtrees, one PR per subtree. #10326 (telemetry exporters) and #10327 (telemetry Apollo reporting) have merged, so this PR is now based directly ondev-v3.x. Both followed #10317 for ROUTER-2142, part of ROUTER-2132. #10326 explains the conversion pattern and the parse-time validation path.Intent
Two sections used to ignore keys they didn't define, and now reject them:
telemetry.instrumentation.events.router.my.event, a misspelledlevle: warnbesidelevel: infowas dropped.levelandconditionform of the standardrequest,responseanderrorevents. Aconditon:typo next to a realcondition:was dropped.Both are in the breaking changeset and the v3 upgrade guide's unknown-key note. Everything else in the section parses as before; in the schema snapshot, the event definitions gain
additionalProperties: falseand optional selector fields gaindefault: null. The plugin's existing selector-stage checks still only log warnings; this PR doesn't change them.Why this approach
Most types take the macro directly. Fields that serde treated as required keep
#[config(required)]. That matters most for the untagged selector enums: each variant is told apart by its key (for exampleconnector_http_method), and if that key defaulted, an empty map would match the first variant. The schema snapshot'srequiredlists are unchanged, which confirms none was lost.Three groups of types can't use the macro. Each has a small hand-written
Validateimpl with a comment:DefaultandValidateimpls without the type's generic parameters, so it can't compile a generic type.Extendable,Conditional,Condition,SelectorOrValue,StandardEventConfig, the customEvent,DefaultedStandardInstrument,Instrument,InstrumentValueand the instrumentEventandFieldkeep their serde and schemars derives. Their impls forward validation to their nested sections under the same keys the macro would use; untagged enums validate at their own path. These impls are temporary debt: a follow-up apollo-configuration ticket adds generic support to the macro, after which they can be removed and the types converted. This PR doesn't change apollo-configuration.JsonPathInst, which has noDebugimpl for the macro's derive, nor aValidateimpl. Every other field is a scalar or unit enum, so theirValidateimpls are empty. This is the same reason ROUTER-2142 kept the headers plugin'sOperationhand-written.AttributeValue. This PR adds its impl. One variant wraps a plainf64, which has noValidateimpl, so the macro can't derive one for that variant. No variant has a rule to check, so the impl is empty. Every selector'sstaticanddefaultfields, andSelectorOrValue's constant value, use it.The first commit is a mechanical rename. Seven types had an inherent
validatemethod that checks selector stages. Once they also implement theValidatetrait, the macro's generatedself.field.validate(errors)call resolves to the inherent method first and doesn't compile. Renaming the inherent methods tovalidate_selectorskeeps the two apart; behaviour is unchanged.services::header_masking::RedactMode, a unit enum the selectors use, converts too. The connector and HTTP client selectors dropderivativefor a plainPartialEqderive, because the macro now providesDebug.How it was verified
router.yaml, docs example and dockerfile config) passes with the stricter types. Migration2048-static-string-selector-deprecatedrewrites values under event attributes, not keys at the event level, and passes.Risk
Breaking, v3 only: an unknown key in a custom event, or in the
level/conditionform of a standard event, now fails to load.router config validatereports it.