fix: expand ${VAR_NAME} brace syntax in MCP config env var expansion#1712
fix: expand ${VAR_NAME} brace syntax in MCP config env var expansion#1712coleam00 wants to merge 4 commits into
Conversation
The regex in expandEnvVarsInRecord only matched $VAR_NAME but silently
passed through ${VAR_NAME} — the standard form used in Docker Compose,
shell scripts, and most MCP server documentation. Updated the regex to
handle both forms and added 4 tests covering brace syntax, mixed syntax,
missing vars, and headers expansion.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add clarifying comment to unreachable fallback in expandEnvVarsInRecord. The regex alternation guarantees one capture group always matches when the replace callback fires, making the '' branch unreachable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- piv-plan.md: add ESLint constraint verification step to Phase 2 ANALYZE and a lint-check bullet to Phase 4 VERIFY, preventing plans from recommending TypeScript constructs that project ESLint rules prohibit - piv-plan.md: add cross-package test rationale note to Testing Strategy table, removing implementer hesitation when test files cross package boundaries - CLAUDE.md: document the as T / ! double-prohibition dead-end in ESLint Guidelines so implementers and plan authors see the correct ?? fallback pattern upfront Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
Closing — this PR was produced by an end-to-end test run of the piv-system-evolution workflow, not a real contribution. The MCP ${VAR} fix itself is correct and may be reopened/reused separately. |
Summary
expandEnvVarsInRecordinpackages/providers/src/mcp/config.tsonly expanded bare$VAR_NAMEreferences; brace-style${VAR_NAME}— the standard form in Docker Compose, shell scripts, and most MCP server documentation — was silently passed through as a literal string.${VAR_NAME}) received broken API tokens and database URLs at runtime with no error or warning..archon/as part of the AI-layer evolution.UX Journey
Before
After
Architecture Diagram
Before / After
Connection inventory:
Label Snapshot
risk: lowsize: XSprovidersproviders:mcpChange Metadata
bugprovidersLinked Issue
Validation Evidence (required)
Package breakdown: @archon/git 142, @archon/cli 226, @archon/providers 381, @archon/core 831, @archon/web 158, @archon/paths 170, @archon/isolation 251, @archon/server 233, @archon/adapters 344, @archon/workflows 930.
Security Impact (required)
Compatibility / Migration
$VAR_NAMEexpansion is unchanged; only adds support for${VAR_NAME}Human Verification (required)
${VAR(falls through unexpanded), missing vars in brace form (empty string +missingVarslist), mixed forms in same stringSide Effects / Blast Radius (required)
expandEnvVarsInRecordin@archon/providers)$VARpaths are unchangedresult.missingVarslist already surfaces undefined vars to callersRollback Plan (required)
packages/providers/src/mcp/config.tsregex to single-capture form${VAR}strings instead of resolved valuesRisks and Mitigations
${without closing}— LOW. The alternation requires\{...\}to be complete; an unclosed brace falls through to the bare-var branch or passes through unexpanded. Covered by the missing-var test.as stringvs?? ''ESLint conflict — RESOLVED. The@typescript-eslint/non-nullable-type-assertion-style+@typescript-eslint/no-non-null-assertionrules together prohibit bothas Tand!. Resolution:braced ?? bare ?? ''with an inline comment explaining the''branch is unreachable. This pattern is now documented in CLAUDE.md for future implementers.AI-Layer Changes (PIV run)
This branch was implemented and validated by a PIV (Plan-Implement-Validate) run. The following AI-layer files were evolved based on findings:
.archon/commands/piv-plan.md— Added ESLint constraint verification step to Phase 2 ANALYZE and Phase 4 VERIFY, so future plan authors check TypeScript construct compatibility with project ESLint rules before recommending them in GOTCHA sections. Added cross-package test rationale note to the Testing Strategy table template.CLAUDE.md— Added "Type-assertion dead-end (Archon-specific)" section under ESLint Guidelines documenting that@typescript-eslint/non-nullable-type-assertion-style+@typescript-eslint/no-non-null-assertionprohibit bothas Tand!; the compliant resolution is?? fallbackwith an inline comment..archon/commands/piv-*.md+.archon/workflows/piv-system-evolution.yaml— PIV workflow command files and the system-evolution workflow added to the repo.