Implement platform-product config and governance tagging defaults#7
Implement platform-product config and governance tagging defaults#7
Conversation
There was a problem hiding this comment.
Summary
This PR introduces platform configuration and governance tagging infrastructure with typed environment validation. The implementation is generally sound, but contains 2 critical logic errors that must be fixed before merge.
Critical Issues (Must Fix)
-
Silent default to 'dev' environment (lib/platform-config.ts:35-37): The code defaults to 'dev' when no environment is specified, creating a dangerous scenario where production deployments could accidentally use development configuration if environment variables aren't set. This contradicts the documented "fail-fast" behavior and violates the principle of explicit configuration.
-
Documentation-implementation mismatch (README.md:79): The README claims "fail-fast errors" but the implementation silently defaults, misleading users about the actual behavior.
Required Actions
Fix the resolvePlatformEnvironment function to throw an error when no environment is specified, ensuring deployments fail explicitly rather than defaulting to an incorrect environment. This aligns the implementation with the documented "fail-fast" behavior and prevents potentially catastrophic misconfigurations.
Once these critical issues are resolved, the PR will provide robust environment validation and governance tagging capabilities.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
| if (!normalized) { | ||
| return 'dev'; | ||
| } |
There was a problem hiding this comment.
🛑 Logic Error: Silently defaulting to 'dev' when no environment is specified creates a critical risk where production deployments could accidentally use development configuration if PLATFORM_ENV or platformEnv context are not set. This violates the principle of failing safely and could lead to incorrect infrastructure provisioning. Throw an error instead to force explicit environment selection.
| if (!normalized) { | |
| return 'dev'; | |
| } | |
| if (!normalized) { | |
| throw new Error( | |
| 'Platform environment must be explicitly specified via platformEnv context or PLATFORM_ENV. Allowed values: dev, stage, prod.', | |
| ); | |
| } |
|
|
||
| The CDK app now applies two productized guardrails from the platform review recommendations: | ||
|
|
||
| - **Typed environment configuration** via `lib/platform-config.ts` with explicit `dev|stage|prod` validation and fail-fast errors for invalid values. |
There was a problem hiding this comment.
🛑 Logic Error: The README claims "fail-fast errors for invalid values" but the implementation silently defaults to 'dev' when no environment is specified (line 36 in platform-config.ts). This creates a critical mismatch where production deployments could accidentally use dev configuration if environment variables are not set. Update documentation to accurately reflect the default behavior or fix the implementation to fail-fast on missing values.
Motivation
Description
lib/platform-config.ts) withdev|stage|prodvalidation and per-environment default metadata values.PLATFORM_ENVand pass it into the stack viabin/app.ts.platformConfig(CdkAppStackProps) and replace ad-hoc tags with standardized governance tags (environment,project,owner,cost-center,data-classification) sourced from config inlib/cdk-app-stack.ts.test/cdk-app-stack.test.ts,test/__snapshots__/cdk-app-stack.test.ts.snap) and add README documentation describing the new guardrails and how to select the environment.Testing
npm run buildsuccessfully.npm test -- --runInBandand all tests passed.npm run synth -- -c platformEnv=stageand synthesis completed successfully (non-blocking Node/CDK warnings were emitted).Codex Task