Add generic x-deprecation-message schema walker; emit warning when deprecated frontmatter fields are set#33362
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…hen deprecated fields are set Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds schema-driven detection of deprecated frontmatter fields so the compiler emits user-visible warnings whenever deprecated fields are present, using x-deprecation-message (fallback to description) from the JSON schema.
Changes:
- Implemented a deep JSON-schema walker to collect deprecated fields (with dot-paths) and find them in nested frontmatter.
- Wired compiler warnings to emit one warning per deprecated field found during compilation.
- Updated schema to include
x-deprecation-messagefor additional deprecated fields and added tests covering the new warning behavior.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/schema_deprecation.go | Adds deep deprecated-field collection and nested frontmatter lookup by dot-path. |
| pkg/workflow/compiler_orchestrator_tools.go | Emits schema-driven deprecation warnings during tools/markdown processing. |
| pkg/workflow/tools_parser.go | Removes the hard-coded tools.github.repos deprecation warning (now handled generically). |
| pkg/workflow/compiler_orchestrator_tools_test.go | Adds tests capturing stderr to verify deprecation warnings are emitted. |
| pkg/parser/schemas/main_workflow_schema.json | Adds x-deprecation-message to selected deprecated fields (schema as source of truth). |
| pkg/parser/schema_deprecated_test.go | Adds unit tests for the deep schema walker and deep frontmatter matching. |
| pkg/parser/README.md | Documents the new deep deprecated-field APIs. |
| .github/workflows/mcp-inspector.lock.yml | Updates the Datadog header env var reference (DD_APPLICATION_KEY value source). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/8 changed files
- Comments generated: 4
| func collectDeprecatedDeep(schemaNode map[string]any, parentPath string, results *[]DeprecatedField) { | ||
| properties, ok := schemaNode["properties"].(map[string]any) | ||
| if !ok { | ||
| return | ||
| } |
| Replacement string // The recommended replacement field name | ||
| Description string // Description from the schema | ||
| Name string // The deprecated field name (leaf key only) | ||
| Path string // Full dot-separated path, e.g. "tools.grep" (empty for top-level fields) |
| // captureStderr redirects os.Stderr to a pipe and returns the captured output | ||
| // after calling fn. The original os.Stderr is always restored. | ||
| func captureStderr(fn func()) string { | ||
| oldStderr := os.Stderr | ||
| r, w, _ := os.Pipe() | ||
| os.Stderr = w | ||
| fn() | ||
| w.Close() | ||
| os.Stderr = oldStderr | ||
| var buf bytes.Buffer | ||
| buf.ReadFrom(r) | ||
| return buf.String() |
| compiler.warnDeprecatedFrontmatterFields(frontmatter) | ||
| }) | ||
|
|
||
| assert.Empty(t, strings.TrimSpace(stderr), "no warning should be emitted for non-deprecated fields") |
|
@copilot resolve the merge conflicts in this pull request |
…dd-x-deprecation-message-walker # Conflicts: # pkg/parser/schemas/main_workflow_schema.json Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Resolved in the latest commit. The only conflict was in |
Deprecated fields marked in the JSON schema (e.g.
tools.grep) were silently accepted at compile time — no warning reached the user. The only exception was a hand-coded warning fortools.github.repos, meaning every new deprecation required manual plumbing.Approach
Replace per-field hard-coding with a schema-driven walker that runs once per compilation and emits
x-deprecation-message(falling back todescription) for every deprecated field present in the frontmatter.pkg/parser/schema_deprecation.goDeprecatedFieldwithPath(dot-notation path, e.g.tools.grep) andDeprecationMessage(x-deprecation-messagevalue)collectDeprecatedDeep()— recursive walker overproperties, flatteningoneOf/anyOf/allOfvariants so nested fields liketools.github.repos(buried inoneOf[3]) are discovered automaticallyGetMainWorkflowDeprecatedFieldsDeep()— cached entry pointFindDeprecatedFieldsInFrontmatterDeep()— navigates nested frontmatter maps by dot-separated pathpkg/parser/schemas/main_workflow_schema.jsonx-deprecation-messagetotools.github.repos(preserving thegh aw fixmigration hint),tools.github.toolset, andtools.serena— schema is now the single source of truth for all deprecation messagespkg/workflow/compiler_orchestrator_tools.gowarnDeprecatedFrontmatterFields()calls the deep walker and emitsFormatWarningMessagefor every hit; wired intoprocessToolsAndMarkdownpkg/workflow/tools_parser.gotools.github.reposwarning (and its unusedconsole/osimports)Result
A workflow using
tools.grep: truenow produces at compile time:Future schema deprecations self-document without any parser changes.