Skip to content

feat(config): hint when a config key requires a newer schema version#3550

Merged
dgageot merged 1 commit into
docker:mainfrom
dgageot:feat/config-version-hint
Jul 9, 2026
Merged

feat(config): hint when a config key requires a newer schema version#3550
dgageot merged 1 commit into
docker:mainfrom
dgageot:feat/config-version-hint

Conversation

@dgageot

@dgageot dgageot commented Jul 9, 2026

Copy link
Copy Markdown
Member

When a config file fails strict YAML parsing, the error message today gives no guidance on why — it just says the key is unknown. This is particularly confusing when someone copies a snippet from the docs that uses a feature introduced in a newer schema version, because the fix is simple (bump the top-level version field) but invisible from the error alone.

This change adds a hint in that failure path. After a strict parse fails, the code probes each parser for schema versions above the one declared in the file, finds the smallest version that successfully parses the document, and appends a message like:

hint: this key is supported by config version 11; update the top-level 'version' field (currently 10)

The probing is cheap — it only runs when strict parsing has already failed — and is gated on finding a strictly higher version that actually accepts the input, so it stays silent when the error is a genuine typo or unsupported key. A follow-up commit adds a numeric version ordering test and expands the newerVersionHint doc comment.

@dgageot
dgageot requested a review from a team as a code owner July 9, 2026 10:54

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The newerVersionHint implementation is clean and correct. The logic correctly:

  • Gates on *yaml.UnknownFieldError (so type mismatches and genuine typos stay silent)
  • Compares version numbers numerically (not lexicographically), preventing "9" > "10"-style ordering bugs
  • Picks the smallest accepting version, giving users the most precise upgrade target
  • Only runs on the already-failed error path — no performance impact on the happy path

The doc comment honestly acknowledges the best-effort nature of the hint (a newer parser accepting the doc for unrelated reasons). Test coverage via TestLoadUnknownKeyFromNewerVersionHint, TestLoadUnknownKeyNoNewerVersionNoHint, and TestLoadNewerVersionHintNumericOrdering is solid for the key scenarios.

No bugs or significant concerns found in the changed code.

@aheritier aheritier added area/config For configuration parsing, YAML, environment variables kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Jul 9, 2026
@dgageot
dgageot force-pushed the feat/config-version-hint branch from 24415b6 to 1c77982 Compare July 9, 2026 11:39
@dgageot
dgageot merged commit f04193c into docker:main Jul 9, 2026
8 checks passed
Piyush0049 pushed a commit to Piyush0049/docker-agent that referenced this pull request Jul 10, 2026
Piyush0049 pushed a commit to Piyush0049/docker-agent that referenced this pull request Jul 15, 2026
feat(config): hint when a config key requires a newer schema version
Piyush0049 pushed a commit to Piyush0049/docker-agent that referenced this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config For configuration parsing, YAML, environment variables kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants