feat(config): auto type inference + provenance/merge bug fixes - #2897
feat(config): auto type inference + provenance/merge bug fixes#2897Erik Osterman (Cloud Posse) (osterman) wants to merge 3 commits into
Conversation
…e and merge bugs Adds --type=auto (the new default) to `atmos config set` and `atmos stack set`: it infers from the Atmos config schema, then from the type of the value already at the path, warning instead of silently stringifying when neither source has an answer. `atmos stack set` previously never inferred at all. Also fixes several bugs found during a field-test pass of the config/stack commands: - MCPSettings.Enabled (bool + omitempty) could vanish entirely when merging atmos.yaml with an atmos.d fragment that both set it; now a *bool. - PickProvenanceFile picked a phantom Line:0 provenance entry over the real defining file for values that live only in an imported catalog manifest, breaking `stack set/delete/get/list` for the standard catalog+import pattern. This also fixed an independent copy of the same bug in the AI/MCP tools layer. - Error hints containing a raw <placeholder> were silently stripped by the markdown renderer (parsed as inline HTML); now HTML-entity-escaped outside backtick spans. - `--config a.yaml,b.yaml` on edit commands silently targeted only the first file; now warns. - `config get` on a key defined only in an atmos.d fragment returned a bare "not found" with no indication it might be defined elsewhere. - `unset` alias was missing from `--help` output for config/stack delete. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
Warning Review limit reached
Next review available in: 20 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThe change adds automatic type inference for configuration and stack setters, catalog-aware provenance editing, nullable MCP enablement, safe error hint rendering, and complete subcommand alias display. Documentation, fixtures, and regression tests cover the new behavior. ChangesConfiguration and stack value management
MCP enablement state
Error and help output
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
pkg/yaml/edit_test.go (1)
156-173: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse table-driven tests for the new type-inference scenarios.
Each site tests independent scenarios with repeated setup and assertions. Use named table cases so each type and fallback case runs independently.
pkg/yaml/edit_test.go#L156-L173: Table-drive boolean, integer, string, float, null, and missing-path cases.pkg/yaml/edit_test.go#L251-L265: Table-drive successful lookup, missing-path, and missing-file cases.cmd/stack/operations_test.go#L400-L463: Table-drive existing-value inference and new-key string-fallback cases.As per coding guidelines, “Use table-driven tests for testing multiple scenarios in Go.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/yaml/edit_test.go` around lines 156 - 173, Convert the independent scenarios into named table-driven tests: in pkg/yaml/edit_test.go lines 156-173, cover boolean, integer, string, float, null, and missing-path cases; in pkg/yaml/edit_test.go lines 251-265, cover successful lookup, missing-path, and missing-file cases; and in cmd/stack/operations_test.go lines 400-463, cover existing-value inference and new-key string fallback. Run each case through the relevant existing test logic with per-case assertions.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@errors/builder.go`:
- Around line 191-218: Update escapeHintAngleBrackets to use a delimiter-aware
scanner that preserves Markdown code spans with one or more backticks, including
``--file <manifest>``; stop relying on backtickSpanPattern’s single-backtick
regex and ensure angle brackets inside every valid code span remain unchanged.
Add the requested regression case to TestEscapeHintAngleBrackets.
In `@pkg/yaml/edit.go`:
- Around line 199-230: Update GetType to detect path presence without calling
Get, so explicit YAML null values remain distinguishable from missing or
unaddressable nodes. Extend its tag mapping to return TypeNull for !!null while
preserving existing type mappings and failure behavior. Add a regression test
covering auto inference for an existing explicit null value.
In `@pkg/yaml/typed.go`:
- Line 42: Extend looksNonStringPattern to recognize common numeric CLI forms
including scientific notation (such as 1e3), an explicit plus sign (such as +5),
and leading-decimal values (such as .5), while retaining existing booleans,
integers, and decimals. Add regression cases covering these forms and verify
type inference no longer treats them as strings without the fallback warning.
In `@website/blog/2026-08-06-config-stack-type-inference.mdx`:
- Around line 42-46: Update both atmos stack set examples to include the
required -s <stack> and -c <component> selectors, preserving their existing
variable values and type option.
- Around line 45-46: Correct both fallback-warning examples: in
website/blog/2026-08-06-config-stack-type-inference.mdx lines 45-46, either
remove --type=bool to demonstrate automatic fallback or revise the comment to
describe explicit boolean typing; in
website/docs/cli/commands/config/config-set.mdx lines 44-46, remove the warning
claim for production or change the example to use a bool- or number-like value
on a new unmodeled path.
---
Nitpick comments:
In `@pkg/yaml/edit_test.go`:
- Around line 156-173: Convert the independent scenarios into named table-driven
tests: in pkg/yaml/edit_test.go lines 156-173, cover boolean, integer, string,
float, null, and missing-path cases; in pkg/yaml/edit_test.go lines 251-265,
cover successful lookup, missing-path, and missing-file cases; and in
cmd/stack/operations_test.go lines 400-463, cover existing-value inference and
new-key string fallback. Run each case through the relevant existing test logic
with per-case assertions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 857569fc-1397-41bb-9a73-e5342425d3dd
📒 Files selected for processing (36)
cmd/config/operations.gocmd/config/operations_test.gocmd/help_template.gocmd/help_template_test.gocmd/mcp/client/add.gocmd/mcp/client/add_test.gocmd/mcp/client/install.gocmd/mcp/client/list.gocmd/mcp/client/status.gocmd/mcp/client/uninstall.gocmd/mcp/server/start.gocmd/stack/config.gocmd/stack/operations.gocmd/stack/operations_test.goerrors/builder.goerrors/builder_test.goerrors/formatter_test.gopkg/ai/tools/atmos/stack_config_common_test.gopkg/ai/tools/atmos/stack_config_delete_test.gopkg/ai/tools/atmos/stack_config_format_test.gopkg/ai/tools/atmos/stack_config_list_test.gopkg/ai/tools/atmos/stack_config_set_test.gopkg/config/mcp_enabled_merge_test.gopkg/datafetcher/schema/atmos/config/1.0.jsonpkg/schema/mcp.gopkg/stack/edit.gopkg/stack/edit_test.gopkg/yaml/edit.gopkg/yaml/edit_test.gopkg/yaml/typed.gopkg/yaml/typed_test.gowebsite/blog/2026-08-06-config-stack-type-inference.mdxwebsite/docs/cli/commands/config/config-set.mdxwebsite/docs/cli/commands/stack/config/set.mdxwebsite/docs/cli/commands/stack/stack-set.mdxwebsite/src/data/roadmap.js
Adds the durable Atmos project fixture used to manually verify the config/stack fixes in this PR live: multi-level imports, base-component inheritance, YAML anchors/aliases, and an atmos.d fragment -- coverage no existing fixture provided for this command surface. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Reopening to re-trigger CI checks, which never registered on initial open. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
- GetType now correctly distinguishes an explicit YAML null (real, present value) from a missing path, returning (TypeNull, true) instead of ok=false. The auto-inference callers (config/stack set) deliberately still treat an existing null as unresolved, since buildRHS's TypeNull case ignores the value argument and would otherwise silently discard the new value being set. - looksNonStringPattern now recognizes scientific notation (1e3), explicit plus signs (+5), and leading/trailing-dot decimals (.5, 5.), so the fallback-to-string warning fires for these shapes too. - escapeHintAngleBrackets now uses a CommonMark-compliant delimiter-aware code-span scanner instead of a single-backtick regex, so double-backtick-delimited hints are handled correctly. - Fixed two doc examples (blog post + config-set.mdx) that claimed to demonstrate the fallback warning but used commands that couldn't actually produce it (explicit --type, or a value that doesn't look non-string); also added the required -s/-c flags to two stack set examples. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
what
atmos config setandatmos stack setnow default--typetoauto: infer from the Atmos config schema, then from the type of the value already at the path, falling back to a string (with a warning) only when neither source has an answer.atmos stack setpreviously never inferred at all — every value was stored as a string unless--typewas passed explicitly.PickProvenanceFile(shared byatmos stack set/get/delete/listand the AI/MCP tools layer) always picking the last provenance entry, which for any value defined only in an imported catalog file was a phantomLine:0entry pointing at the wrong (importing) manifest instead of the file that actually defines the value.MCPSettings.Enabled(abooltaggedomitempty) silently disappearing from the merged config whenatmos.yamland anatmos.d/fragment both set it to different values, instead of the explicit value winning.<placeholder>(e.g.pass --config <file>.) being silently stripped by the terminal markdown renderer, which parses unescaped angle brackets as inline HTML.--config a.yaml,b.yamlonatmos config get/set/delete/formatnow warns that only the first file is targeted, instead of silently dropping the rest.atmos config geton a key defined only in anatmos.d/fragment now hints to checkatmos describe configinstead of just reporting "not found".unsetalias (forconfig/stack delete) now shows up in--helpoutput, alongsidedel.why
atmos configandatmos stack/atmos stack configsurfaced these as real, reproducible bugs and gaps — silent type corruption, a provenance-resolution bug that broke edits for the standard catalog-import stack pattern, and a config value that could vanish entirely on merge.references
Summary by CodeRabbit
config setandstack setnow automatically infer value types, with warnings when values fall back to strings.<file>in formatted output.