Repository navigation
feat: fail closed when a Building Block mock loads in a deployed environment - #1032
Merged
Merged
Conversation
…ronment Add assertNotMockInDeployedEnv(bbName) to @aws-blocks/core (exported from bb-utils), the runtime counterpart of assertCdkConditionActive. It throws when a BB mock (default export) entry is loaded in a deployed environment, detected compute-agnostically via BLOCKS_CONFIG_BUCKET/BLOCKS_CONFIG_KEY (not AWS_LAMBDA_*), so it covers Lambda, container, AgentCore and other compute targets. Wire it into every BB mock entry; bb-auth-basic is excluded because it has no aws-runtime export (its index.ts is the real runtime). Replace the OIDC mock cookie secret with a per-process random value, pin aws-runtime on three esbuild bundles, and document the bundler-condition requirement.
🦋 Changeset detectedLatest commit: 6101fc8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
📖 Glossary & notes — scoring, indicators, per-metric thresholds (click to expand)
Results — PR vs
|
| Task | Template | Tests | Judge | Cost | Turns | Score | Stop reason |
|---|---|---|---|---|---|---|---|
| async-word-counter | bare | — | — | — | endTurn | ||
| auth-notes | demo | — | — | ❌ $11.08 (+$4.85) | ❌ 45 (+17) | — | endTurn |
| cognito-profile | auth-cognito | — | — | ✨ $3.26 (-$2.34) | ✨ 15 (-10) | ✅ 0 (0) | error |
| collab-presence-board | default | — | — | ✅ $2.07 (-$0.04) | ✅ 17 (+1) | — | endTurn |
| email-digest | demo | — | — | ✅ 28 (+2) | — | endTurn | |
| file-gallery | bare | — | — | ✨ $1.91 (-$0.23) | ✅ 15 (+2) | — | endTurn |
| kb-chat-agent | demo | — | — | ❌ $27.29 (+$5.44) | ❌ 59 (+9) | — | endTurn |
| observability-api | backend | — | — | ✅ $4.4 (-$0.46) | ✅ 24 (-1) | — | endTurn |
| oidc-dsql-notes | react | — | — | ✅ $9.34 (+$0.05) | ✅ 38 (0) | — | endTurn |
| sql-kb-catalog | nextjs | — | — | ❌ $7.44 (+$2.21) | ❌ 36 (+7) | — | endTurn |
Merge verdict
❌ This bench run BLOCKS the PR.
- ❌ Absolute floor — mean composite 0.0 is below the floor 65.
- ✅ Regression vs
main— mean composite delta +0.0 pts vs main is within the 10-pt limit.
The Δ vs base ball above is a fixed ±5-pt display band; the regression gate uses BENCH_MAX_REGRESSION. The ball is cosmetic — the gate threshold is what blocks.
Caveats & exclusions
- 🧰 Excluded (harness_error, not scored) — 9: 9× isolation_unavailable. Cells:
async-word-counter/bare,auth-notes/demo,collab-presence-board/default,email-digest/demo,file-gallery/bare,kb-chat-agent/demo,observability-api/backend,oidc-dsql-notes/react,sql-kb-catalog/nextjs
osama-rizk
approved these changes
Oct 26, 2026
3 tasks done
This was referenced Oct 27, 2026
This was referenced Oct 28, 2026
test(native): codegen fixtures 29-36 and 38, and the auth spec fixtures 18 and 23 (stack 05/24)
#854
Merged
Merged
Merged
Merged
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AWS Blocks selects a Building Block's implementation through npm conditional exports resolved at bundle time:
cdk→ the CDK construct,aws-runtime→ the real AWS-backed implementation, anddefault→ the local-dev mock (in-memory / on-disk stubs).The
cdkcondition is already guarded at runtime byassertCdkConditionActive(), which fails closed when CDK synth runs without--conditions=cdk. Theaws-runtimecondition had no runtime counterpart. If a backend is bundled without theaws-runtimecondition, module resolution falls back to each BB'sdefault(mock) entry, and the deployed artifact runs the mocks with no error, warning, or log line.The framework's own deploy tooling always passes the condition, so this only surfaces when a backend is deployed to a compute target the framework does not configure — a customer's own bundler, a container image, or another serverless platform.
Changes
@aws-blocks/core/bb-utilsnow exportsassertNotMockInDeployedEnv(bbName), the runtime counterpart of the--conditions=cdksynth check. It throws when a Building Block's mock (default) entry is loaded in a deployed environment. "Deployed" is detected fromBLOCKS_CONFIG_BUCKET/BLOCKS_CONFIG_KEY— the same two variables Blocks sets on every compute it configures and that the config loader already uses to tell local-vs-deployed apart — so the check covers Lambda, container, AgentCore, and other compute targets alike. It deliberately does not key offAWS_LAMBDA_*, which would make it Lambda-only. It is a no-op in local dev and tests.bb-auth-basicis intentionally excluded: it has noaws-runtimeexport, so itsindex.tsis its real deployed runtime rather than a mock.globalThissymbol so duplicate module copies share one) instead of a fixed constant. Local sign-in is unchanged; sessions no longer persist across a dev-server restart.@aws-blocks/hostinghandler bundle and the AuthOIDC IdP-registration and distributed-table GSI-manager Lambda bundles now pin theaws-runtimecondition (defense-in-depth; their graphs contain no@aws-blocks/*imports today).docs/guides/extending-with-existing-aws-resources.mddocuments configuring your own bundler with theaws-runtimecondition when deploying to a compute target Blocks doesn't configure, and is explicit that the runtime guard only fires where Blocks sets the config-location variables.Validation
npm run buildandnpm run lintpass.packages/core/src/common/runtime-guard.test.ts): both variables set throws; either one alone does not; neither set is a no-op.packages/core/src/common/runtime-guard.e2e.test.ts) spawns a childnodeprocess importing a real built BB: with the config variables set and without--conditions=aws-runtimeit exits non-zero naming the guard; with the condition it loads; with neither variable set it loads.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.