-
Notifications
You must be signed in to change notification settings - Fork 200
feat(cli): add ENV var interpolation support to router compose input file
#2413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(cli): add ENV var interpolation support to router compose input file
#2413
Conversation
WalkthroughThe changes add environment variable interpolation support to the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
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 |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (71.42%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2413 +/- ##
==========================================
+ Coverage 1.49% 29.20% +27.70%
==========================================
Files 292 127 -165
Lines 46926 11051 -35875
Branches 431 254 -177
==========================================
+ Hits 703 3227 +2524
+ Misses 45940 7822 -38118
+ Partials 283 2 -281 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
cli/src/commands/router/commands/compose.ts (1)
33-41: Consider documenting edge cases.While the implementation is solid, you may want to document two behaviors for users:
- Missing variables: Undefined environment variables are replaced with empty strings (rather than causing errors or warnings).
- YAML special characters: Environment variable values containing YAML special characters (quotes, colons, etc.) could break YAML syntax. Users should ensure proper quoting in their input files.
For example, add to the JSDoc:
/** * Expands environment variables in a string using ${VAR_NAME} syntax. * Consistent with Go's os.ExpandEnv() used in router config.yaml. + * + * @param content - The string content to expand + * @returns The content with all ${VAR_NAME} patterns replaced by their values, + * or empty strings for undefined variables + * @note Ensure environment variable values are properly escaped for YAML context */
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cli/src/commands/router/commands/compose.ts(2 hunks)cli/test/expand-env-vars.test.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
cli/test/expand-env-vars.test.ts (3)
1-14: LGTM! Clean test setup.The environment snapshot and restore pattern is appropriate. The ESLint disable is necessary for the test strings containing
${VAR}patterns.
16-40: Excellent test coverage.The test cases cover all essential scenarios including edge cases like adjacent variables and the important behavior of replacing missing variables with empty strings.
42-49: Great practical test case!This test validates the primary use case described in the PR objectives: interpolating sensitive authorization tokens in headers. The multi-line YAML-like format makes the test realistic.
cli/src/commands/router/commands/compose.ts (2)
195-197: LGTM! Integration point is correct.The expansion is applied at the right time—after file read but before YAML parsing. This ensures that both main subgraphs and feature flag configurations benefit from environment variable interpolation, directly addressing the PR objective of handling sensitive introspection headers.
33-41: Implementation correctly follows Go'sos.ExpandEnvbehavior.The regex pattern appropriately handles
${VAR_NAME}syntax, and the use ofprocess.env[varName] ?? ''correctly returns an empty string for undefined variables, matching Go's documented behavior. The code is secure with no injection risks.
Summary by CodeRabbit
${VARIABLE_NAME}syntax to reference environment values.✏️ Tip: You can customize this high-level summary in your review settings.
Checklist
Resolves #2002
Will follow up with a docs PR soon