Check the type a CRD declares, not just presence and shape - #205
Merged
Conversation
The walker asked whether every required property was present, whether any
property was excess, and whether list identities were unique. It never asked
whether a value carried the type the CRD declares — and YAML decides that for
you.
That gap has a live cost. portal's Platform declared
minACU: 0.5
maxACU: 4
which reads as obviously correct and is not: the CRD types both as STRINGS,
because Kubernetes serialises fractional quantities that way. The API server
refused the whole object:
spec.datastores[0].relational.minACU: Invalid value: "number":
... in body must be of type string: "number"
Every property was present, none was excess, no list repeated an identity —
so this walker had already declared that manifest admissible, and the install
failed applying it after the cluster and its substrate were built.
The check covers scalars and containers, with two details that matter:
- a Python bool is an int, so `true` would otherwise satisfy `integer`. It is
tested for first, in both directions.
- the message reports the value's OWN type in `Invalid value`, the way the API
server does, so it can be searched for verbatim after a failed apply. A
number where a string is wanted also says to quote it, because that is the
fix and it is not obvious from the type names alone.
Twelve self-test cases: a number and an integer where a string is wanted, the
same value quoted, a string where an integer is wanted, a bool against integer
and against boolean. Every hand-written Platform, Tenant, BudgetPolicy,
ModelGateway, AgentFleet and EvalSuite in the org still passes with the rule
on — thirty-one documents — so it adds no false positives.
CI Results
All checks passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The walker asked whether every required property was present, whether any property was excess, and whether list identities were unique. It never asked whether a value carried the type the CRD declares — and YAML decides that for you.
The live cost
portal's Platform declared:
which reads as obviously correct and is not. The CRD types both as strings, because Kubernetes serialises fractional quantities that way. The API server refused the whole object:
Every property was present, none was excess, no list repeated an identity — so this walker had already declared that manifest admissible, and the install failed applying it after the cluster and its substrate were built.
Two details that matter
truewould otherwise satisfyinteger. Tested for first, in both directions.Invalid value, the way the API server does, so it can be searched for verbatim after a failed apply. A number where a string is wanted also says to quote it, because that is the fix and it is not obvious from the type names alone.Verified
Twelve new self-test cases: a number and an integer where a string is wanted, the same value quoted, a string where an integer is wanted, a bool against
integerand againstboolean.Every hand-written Platform, Tenant, BudgetPolicy, ModelGateway, AgentFleet and EvalSuite in the org — 31 documents across eight files — still passes with the rule on, so it adds no false positives.