fix: resolve CRD property names that contain dots #636

Merged
tobru merged 2 commits from fix/dotted-crd-property-keys into main 2026-08-18 12:12:22 +00:00
Owner

Some CRDs keep INI-style sections as literal keys containing dots, e.g. Forgejo's config has 'service' and 'service.explore' as siblings. Splitting a field path on "." blindly therefore addresses the wrong place, and reads and writes have to agree on which reading wins.

walk_schema_path is now the single source of that precedence (longest literal property key first); split_field_path, is_valid_field_path, get_field_schema and get_schema_type are thin consumers of it, and get_value_at_path applies it to reads. Where no schema is reachable, the data's own keys are searched with backtracking instead of committing to the first shorter key and dying in a dead end.

Both drift checks now derive the expected value through the same parse and coerce pipeline the writer uses, so a bool in a map of strings is compared as "true" rather than True. That also fixes coercion being skipped for hardcoded param paths written without the redundant 'spec.' prefix.

Some CRDs keep INI-style sections as literal keys containing dots, e.g. Forgejo's config has 'service' and 'service.explore' as siblings. Splitting a field path on "." blindly therefore addresses the wrong place, and reads and writes have to agree on which reading wins. walk_schema_path is now the single source of that precedence (longest literal property key first); split_field_path, is_valid_field_path, get_field_schema and get_schema_type are thin consumers of it, and get_value_at_path applies it to reads. Where no schema is reachable, the data's own keys are searched with backtracking instead of committing to the first shorter key and dying in a dead end. Both drift checks now derive the expected value through the same parse and coerce pipeline the writer uses, so a bool in a map of strings is compared as "true" rather than True. That also fixes coercion being skipped for hardcoded param paths written without the redundant 'spec.' prefix.
fix: resolve CRD property names that contain dots
All checks were successful
Tests / test (push) Successful in 1m14s
262fd01de9
Some CRDs keep INI-style sections as literal keys containing dots, e.g.
Forgejo's config has 'service' and 'service.explore' as siblings. Splitting
a field path on "." blindly therefore addresses the wrong place, and reads
and writes have to agree on which reading wins.

walk_schema_path is now the single source of that precedence (longest
literal property key first); split_field_path, is_valid_field_path,
get_field_schema and get_schema_type are thin consumers of it, and
get_value_at_path applies it to reads. Where no schema is reachable, the
data's own keys are searched with backtracking instead of committing to the
first shorter key and dying in a dead end.

Both drift checks now derive the expected value through the same parse and
coerce pipeline the writer uses, so a bool in a map of strings is compared
as "true" rather than True. That also fixes coercion being skipped for
hardcoded param paths written without the redundant 'spec.' prefix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fix: harden CRD dotted path resolution
All checks were successful
Tests / test (push) Successful in 1m8s
eda6bfb05d
Follow-up to 262fd01, from review of that change.

- A CRD schema can carry "properties": None, since the Kubernetes
  client emits unset attributes as None rather than omitting them.
  Reading it unguarded crashed instance create/update and both drift
  checks.
- A bool under a map of strings is written as "true", so comparing
  against the parsed True reported drift forever whenever the schema
  was unavailable to coerce the expected value.
- Longest-literal-key matching now backtracks, so a path only
  reachable through a nested reading still resolves.
- A map's keys are absent from the schema, so resolution falls back to
  the data itself: reads no longer depend on control plane
  reachability, and writes return a value to the literal key it was
  read from instead of a nested duplicate.
- An empty field path addressed the whole spec instead of nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
tobru merged commit 0eacb45e7d into main 2026-08-18 12:12:22 +00:00
tobru deleted branch fix/dotted-crd-property-keys 2026-08-18 12:12:22 +00:00
Sign in to join this conversation.
No description provided.