Resolve env-dependent storybook.registry via allow-listed interpolation#3486
Resolve env-dependent storybook.registry via allow-listed interpolation#3486clintandrewhall wants to merge 2 commits into
Conversation
docset.yml is committed and static, but storybook.registry is environment-dependent (local, per-PR preview, main). Resolving it from an allow-listed environment variable lets one committed value serve every environment without per-env edits. The allow-list is required because docs-builder renders untrusted PR branches, so unrestricted env access would be a secret-exfiltration vector. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 25 minutes and 33 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR implements environment-variable interpolation for configuration values, specifically Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
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: 1
🤖 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
`@tests/Elastic.Documentation.Configuration.Tests/ConfigurationFileStorybookRegistryTests.cs`:
- Around line 43-50: The test DisallowedVariable_IsLeftLiteral_AndWarns
currently asserts only that config.StorybookRegistry remains the literal and
does not contain the secret; update the test to also assert that the
DiagnosticsCollector (collector) recorded a warning. After creating config via
CreateConfiguration(...) and before completing the test, add an assertion that
collector contains at least one warning entry (or a specific warning message) to
verify the warning path is exercised.
🪄 Autofix (Beta)
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: Enterprise
Run ID: 433b691f-3bf0-4666-a3da-e958b6a42ba5
📒 Files selected for processing (15)
docs/syntax/storybook.mdsrc/Elastic.Documentation.Configuration/BuildContext.cssrc/Elastic.Documentation.Configuration/Builder/ConfigurationFile.cssrc/Elastic.Documentation.Configuration/EnvironmentInterpolation.cssrc/Elastic.Documentation/IDocumentationContext.cssrc/Elastic.Markdown/Myst/Directives/Storybook/StorybookBlock.cstests/Elastic.Documentation.Configuration.Tests/ApiConfigurationTests.cstests/Elastic.Documentation.Configuration.Tests/ConfigurationFileExcludeTests.cstests/Elastic.Documentation.Configuration.Tests/ConfigurationFileStorybookRegistryTests.cstests/Elastic.Documentation.Configuration.Tests/CrossLinkRegistryTests.cstests/Elastic.Documentation.Configuration.Tests/EnvironmentInterpolationTests.cstests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cstests/Elastic.Markdown.Tests/Directives/StorybookTests.cstests/Navigation.Tests/TestDocumentationSetContext.cstests/authoring/Framework/CrossLinkResolverAssertions.fs
The DisallowedVariable_IsLeftLiteral_AndWarns test named the warning path but never verified it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Closes #3485
Why
docset.ymlis a committed, static artifact, butstorybook.registryis inherently environment-dependent: local serve, per-PR preview, andmain/production each need a different URL that varies only in one ref segment. Today contributors hand-editdocset.ymlper environment and revert before merge, which is error-prone. The actor that knows the ref at render time is the build/preview layer, not the author at commit time.What
storybook.registrynow supports shell-style environment interpolation with a committed default, so one committed value works everywhere:${VAR}/${VAR:-default}resolve with familiar shell semantics. With no env var set (e.g. amainbuild) the committed default is used byte-for-byte.KIBANA_STORYBOOK_REGISTRY). Any other name is never read from the process environment — it is left literal and a warning is emitted — so a maliciousdocset.ymlcannot exfiltrate CI secrets such as${AWS_SECRET_ACCESS_KEY}.The substitution primitive lives in
Elastic.Documentation.Configurationand is repo-agnostic: docs-builder does not know how to construct a Kibanapr-<N>URL; the consumer supplies the variable.IEnvironmentVariablesis threaded throughIDocumentationSetContextso configuration resolution is injectable and the set/unset/fallback cases are deterministic in tests.