fix(compile): reject unknown front-matter fields with deny_unknown_fields#409
Merged
Merged
Conversation
…elds Add #[serde(deny_unknown_fields)] to FrontMatter so typos like 'safeoutputs:' (instead of 'safe-outputs:') or top-level 'schedule:' (instead of 'on: schedule:') produce a clear compile error rather than being silently ignored. Previously, unknown YAML keys were silently dropped by serde, which meant write-requiring safe-outputs could bypass the validate_write_permissions check entirely, leading to confusing runtime errors (e.g. 'AZURE_DEVOPS_ORG_URL not set'). Also fixes all example files and docs that incorrectly used top-level 'schedule:' instead of 'on: schedule:'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8f5939b to
040364c
Compare
Contributor
🔍 Rust PR ReviewSummary: Solid fix for a real silent-failure bug. One minor documentation typo was introduced alongside the fix. Findings🐛 Bugs / Logic Issues
✅ What Looks Good
|
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.
Problem
FrontMatterdidn't use#[serde(deny_unknown_fields)], so serde silently ignored any YAML key that didn't match a struct field. This caused a real bug where a user wrotesafeoutputs:(no hyphen) instead ofsafe-outputs:— the config was silently dropped, bypassing thevalidate_write_permissionscompile-time check entirely. The result was a confusing runtime error (AZURE_DEVOPS_ORG_URL not set) instead of a clear compile-time error.The same class of bug affected all three example files, which used top-level
schedule:instead ofon: schedule:— their schedules were silently ignored.Fix
#[serde(deny_unknown_fields)]toFrontMatterso any unrecognized YAML key produces a clear compile error listing all valid fields.schedule:(should beon: schedule:).safeoutputs:and top-levelschedule:are rejected, andsafe-outputs:is accepted.Changes
src/compile/types.rs#[serde(deny_unknown_fields)]toFrontMatter+ 3 regression testsexamples/*.md(3 files)schedule:→on: schedule:README.mdon: schedule:docs/front-matter.mdon: schedule:Testing
cargo clippy --all-targets --all-featuresclean