Skip to content

fix(validation): report non-string YAML keys - #178

Merged
rng1995 merged 4 commits into
NVIDIA:mainfrom
rioyu123:codex/frontmatter-mapping-keys
Oct 5, 2026
Merged

rng1995 merged 4 commits into
NVIDIA:mainfrom
rioyu123:codex/frontmatter-mapping-keys

Conversation

@rioyu123

@rioyu123 rioyu123 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

YAML keys can be numbers, booleans, nulls, or dates. Unpacking these mappings into model constructors raises TypeError: keywords must be strings, bypassing normal validation reporting.

Use Pydantic's model_validate() for skill, rule, workflow, and plugin YAML validation, including nested frontmatter metadata. Invalid keys now produce findings instead of aborting validation. Boolean, null, and date keys are shown in a readable form, such as metadata.true or 2026-01-01.

Quoted keys are unchanged: skill, rule, and workflow frontmatter still accept string extras, and plugin manifests still reject unknown fields. Non-mapping input and other validation errors are handled as before. The changelog entry is in the existing Unreleased / Fixed section.

Regression coverage includes each YAML-backed validator, nested metadata, readable error locations, and quoted-key controls.

Verification

  • Linux Python 3.12, locked dependencies with all extras.

  • pytest -q tests/validators: 1,288 passed.

  • make lint and make build: passed.

  • PYTEST_ADDOPTS=-n4 make test: 9,736 passed, 49 skipped, 2 failed. Both failures also occur on the unmodified pre-follow-up head 686d579: managed-runtime command lookup finds the host's installed Codex binary, and a bridge test cannot bind port 18080. That baseline run had 9,697 passed, 49 skipped, and 3 failed, including one additional CLI-banner failure. The full suite is not entirely green in this environment; no new failing test was observed with the patch.

  • I am familiar with the Contributing Guidelines

  • Added or updated focused tests

  • Updated documentation for user-visible changes (changelog)

  • Ran make lint

  • Ran make test (results and limitations above)

  • Ran make build

  • Did not add credentials, private datasets, or proprietary benchmark content

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@rioyu123 Thank you for the contribution and the clear write-up!

The fix is correct for the paths it targets. On main, a rule or workflow frontmatter key such as 123:, true:, null: or 2026-01-01: raises TypeError: keywords must be strings, both at the top level and under metadata. At this head the same inputs are reported as validation errors (Field '123': Keys should be strings, Field 'metadata.123': Keys should be strings). Quoted string keys are still kept as extras, and non-mapping frontmatter is still rejected as before.

Eight of the nine new tests fail on main and all pass here; the quoted-key control passes on both. tests/validators (1,250 tests) and Ruff pass locally, and all 17 CI checks are green.

Inline:

  • The same TypeError is still reachable from the SKILL.md and agent_plugin.yaml validators (P2).
  • Boolean and date keys get confusing field names in the new error (P3).
  • The changelog now has a duplicate ### Fixed heading (P3).

Comment thread CHANGELOG.md Resolved
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
@rioyu123 rioyu123 changed the title fix(validation): report non-string rule and workflow keys fix(validation): report non-string YAML keys Oct 4, 2026
@rioyu123

rioyu123 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @rng1995. The SKILL.md and plugin manifest validators now use model_validate() too, and skill metadata goes through the shared parse_nested_model helper. New regression tests cover numeric, boolean, null, and date keys.

Boolean, null, and date keys now appear in a readable YAML form in error locations, including under metadata. Quoted keys behave as before. I also moved the changelog entry into the existing Fixed section.

All 1,288 validator tests pass, and lint and the package build succeed. The full-suite results, including two environment failures that also occur on the base commit, are in the updated PR description.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@rioyu123 Thank you for the quick turnaround, your patience through the review, and your contribution to SkillEvaluator!

I re-reviewed 294a413 (now at fa14c04 after the update from main). All four comments are addressed:

  • SKILL.md and agent_plugin.yaml: SchemaValidator and PluginSchemaValidator now call model_validate(). Top-level 123:, true:, false:, null:, 1.5:, 2026-01-01: and datetime keys are reported as findings instead of raising TypeError: keywords must be strings.
  • Nested skill metadata: parse_metadata now uses parse_nested_model, so metadata: keys such as 123:, true:, null: and 2026-01-01: report Field 'metadata.<key>': Keys should be strings. metadata: null and normal metadata behave as before.
  • Readable key labels: format_validation_location() renders boolean, null and date keys as true, false, null and 2026-01-01, including under metadata, in the rules, workflows, SKILL.md and plugin validators.
  • Changelog: the entry is now in the existing ### Fixed list.

Validation:

  • Valid and quoted-key inputs give identical findings on main and this branch.
  • Of the 51 new or updated validator tests, 40 fail on main and all pass here.
  • tests/validators passes (1,288 tests) and Ruff is clean.
  • All 17 CI checks pass on fa14c04.

Approved.

@rng1995
rng1995 merged commit 6bab56e into NVIDIA:main Oct 5, 2026
17 checks passed
chrisknvidia added a commit that referenced this pull request Oct 5, 2026
Conflicts:
- validators/plugin_schema.py: keep this branch's structure (bundle
  manifest validation helper, findings cap, inventory imports) and apply
  #178's three changes: import format_validation_location, report the
  location with it, and validate the manifest with
  PluginManifest.model_validate(data) instead of PluginManifest(**data),
  including in this branch's _validate_bundle_manifest, so a non-string
  YAML key becomes an invalid_key finding instead of a TypeError.
- tests/validators/test_plugin_schema.py: keep both sides' tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
@rng1995 rng1995 mentioned this pull request Oct 6, 2026
11 tasks done
rng1995 added a commit that referenced this pull request Oct 14, 2026
Conflicted files:
- tests/validators/test_schema.py: import block only. Both sides added
  `import pytest`; kept it once, plus the PR's SkillFrontmatter import.
  Main's non-string-key tests (#178) and the PR's UTF-8 byte-limit tests
  are both kept.

No semantic breaks found in cleanly merged files: the byte check in
SkillFrontmatter.validate_description_content still runs under main's
model_validate() path and format_validation_location() error reporting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
chrisknvidia pushed a commit that referenced this pull request Oct 30, 2026
* fix(validation): report non-string rule and workflow keys

Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>

* fix(validation): cover remaining YAML keys and clarify errors

Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>

---------

Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
Co-authored-by: Narendran Raghavan <32655573+rng1995@users.noreply.github.com>
chrisknvidia pushed a commit that referenced this pull request Oct 30, 2026
Conflicted files:
- tests/validators/test_schema.py: import block only. Both sides added
  `import pytest`; kept it once, plus the PR's SkillFrontmatter import.
  Main's non-string-key tests (#178) and the PR's UTF-8 byte-limit tests
  are both kept.

No semantic breaks found in cleanly merged files: the byte check in
SkillFrontmatter.validate_description_content still runs under main's
model_validate() path and format_validation_location() error reporting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants