Skip to content

fix(build): decrypt only the .env.local keys box egress routes use - #2863

Open
vvargu wants to merge 13 commits into
aws:box-integrationfrom
vvargu:box/fix-2845-review
Open

vvargu wants to merge 13 commits into
aws:box-integrationfrom
vvargu:box/fix-2845-review

Conversation

@vvargu

@vvargu vvargu commented Nov 19, 2026 •

Copy link
Copy Markdown

Description

This PR fixes a blocking code item from the review of #2845 ("Box integration: review of merged PRs").

1. One undecryptable secret blocks a valid build. Build decrypted every .env.local entry, also the entries that no box egress route uses or that the shell overrides. Now build reads .env.local through the same select and overrides options that the credential provisioner uses:

  • boxKeyVariables(routes) lists the keys that planBoxProfileCredentials reads.
  • boxKeyReads(networks, env) builds the read options. Only non-blank shell values override, the same as the planner.
  • An undecryptable entry still stops the build when a route uses it and the shell does not set it.

2. A blank reserved variable. This PR no longer changes it. box-integration fixes it in 1b5b151: build now replaces a stored key when the route's variable holds a different value, and a blank stored key counts as not set. A new test checks that a blank reserved variable still gets its key when .env.local also holds an unused undecryptable entry.

Related Issue

None.

Documentation PR

Not applicable.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

  • I ran bun test: 5834 pass, 6 skip, 1 fail. The failure is the box on PATH > resolves a profile into the rules the tests fake. It also fails on box-integration without this change, because the local box binary has no metadata_hosts rule.
  • I ran the relevant end-to-end tests with bun run test:e2e, or explained why they are not applicable
    (CI does not run them for you). Not run: the change is in build's local .env.local handling, and the unit tests cover the cases.
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run audit
  • I ran bun run secrets:check
  • I ran bun run build
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them
  • If I re-recorded fixtures or golden files, every change beyond account identifiers is explained
    by this PR

New tests in manager.boxCredentials.test.ts:

  • An unused undecryptable entry does not block the build.
  • An undecryptable entry that the shell overrides does not block the build.
  • An undecryptable entry that a route uses still stops the build.
  • A blank reserved variable gets its key when .env.local also has an unused undecryptable entry.

Build decrypted every .env.local entry before it planned the box egress
credentials, so one undecryptable entry stopped a valid build, even when
no route used it or the shell set its variable.

Build now reads .env.local with the same select and overrides options
that the credential provisioner uses. It reads only each route's env://
variable and the reserved variable of the route's credential, and skips
each variable that the shell sets to a non-blank value. A blank shell
value does not win, so build still reads that variable from the file.

An undecryptable entry that a route uses still stops the build with the
decrypt error.
…env.local

With AGENTCORE_CREDENTIAL_GITHUB= in .env.local and GITHUB_TOKEN set,
build added the github credential but insertIfNew skipped the blank
entry, so the next deploy could not provision it.

insertIfNew takes an optional keep rule. Build passes boxKeyIsSet, the
same rule the credential plan uses to decide which keys need a seed, so
the two cannot disagree again. A blank key gets the seed at its line. A
key the user set stays.

The writer decrypts only the existing keys it must check, so an unused
secret that cannot be decrypted does not block the seed write.
@vvargu
vvargu requested a review from a team November 19, 2026 22:44
@codecov-commenter

codecov-commenter commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.80%. Comparing base (3df8eab) to head (100b38a).

Additional details and impacted files
@@               Coverage Diff                @@
##           box-integration    #2863   +/-   ##
================================================
  Coverage            96.80%   96.80%           
================================================
  Files                  766      766           
  Lines                66928    66979   +51     
================================================
+ Hits                 64790    64841   +51     
  Misses                2138     2138           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@leo237 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of #2863: fixes for the two blocking items from the #2845 review

Decision: APPROVE. I found no correctness bugs, no unhandled silent failures, and no missing tests for the important logic. All findings below are non-blocking.

Plan placement and commit list

  • This is not one of the squashed plan PRs (VV/MQ/SA/TK/DOCS). It is a follow-up fix on box-integration for the two blocking code items from the review of the merged #2845 (VV-2 credentials).
  • I could not check it against the plan doc (squash plan v2), because the doc returned 401. I checked the branches directly instead.
  • The PR has two commits, e9ec0dbd and 1a96f719, and both are new. Neither is a port from box-integration-development: dev has no boxKeyReads, boxKeyVariables, boxKeyIsSet or keep option. Nothing is missing, and there are no extra commits.
  • Nothing is applied twice. The PR has no overlap with the merged PRs, #2859, #2860 or #2862.

Base, conflicts, protected fixes

  • The branch is based on dd36f7b2, so it predates the merge of #2857 (f5503f02). git merge-tree merges it cleanly with the current box-integration, and also with #2859, #2860 and #2862.
  • File overlap:
    • #2859 also touches boxNetworkWriters.ts, manager.tsx and manager.boxCredentials.test.ts, but it merges cleanly.
    • #2860 and #2862 share no files with this PR.
  • No fix that exists only on box-integration is lost. In boxProfileCredentials.ts, the model-provider skip, the key-presence check, the Secrets Manager skip and ENV_LOCAL_RELATIVE_PATH are all unchanged. The PR touches none of the other protected files (boxProfile.ts, the templates, boxMemory, the telemetry code, region, the Dockerfile).

What I checked

  • boxKeyVariables matches the planner. seed is only ever called with credential = route, so credentialEnvVarName(route) is exactly the reserved variable the planner looks up. uniqueRoutes dedupes the same way in both places.
  • The shell value wins only when it is not blank.
    • boxKeyReads passes only non-blank env values as overrides, so an undecryptable file entry whose variable the shell sets is never decrypted.
    • A blank shell value falls through to the file, as the planner expects.
    • readEnvFile merges the overrides into the result, so sources.envLocal now also holds the shell values. The planner checks env first, so its behavior does not change.
  • insertIfNew with keep:
    • It decrypts only the existing keys that are being inserted, and does the in-place replacement with the same ENV_ENTRY span regex as encryptContent.
    • replacements.has guards against duplicate entries.
    • The snapshot and rollback still apply, because the content changes.
    • I checked that parseEnv yields "" for the blank forms export K=, K = , K="" and K= # c, so each of them gets the seed.
  • The two parts agree. build passes boxKeyIsSet as keep, which is the same predicate the planner uses to decide that a seed is needed.

1. Test coverage

The new tests cover the important cases:

  • an unused undecryptable entry;
  • an undecryptable entry that the shell overrides;
  • an undecryptable entry that a route uses, with no shell value and with a blank shell value (the build stops and agentcore.json is unchanged);
  • a blank reserved variable getting the seed, and a set value being kept;
  • a blank reserved variable plus an unused undecryptable entry;
  • insertIfNew with and without keep. The keep test also checks that the value is replaced in place and stays encrypted.

The tests are Windows-safe: they use join, and have no POSIX modes, no sh and no : splitting.

Optional additions:

  • a direct unit test for boxKeyReads (no routes returns undefined; only non-blank overrides are passed);
  • a manager test where the blank reserved line uses the export or "" form.

2. Silent failures

  • One low-risk path: see the inline comment on envLocal.ts:88. A key that KEY_LINE sees but parseEnv does not is skipped with no message, while build still adds the credential.

3. Comment accuracy

  • The comments are accurate, apart from the EnvLocalFile class doc, which still says "never overwriting an existing key" (inline comment).
  • Cross-PR note: the BoxKeySources doc says .env.local is "where agentcore dev stores each box variable under its own name". After #2862 (dev hands box run the keys and no longer writes .env.local), that sentence will be out of date. Whichever of the two PRs merges second should reword it. The doc is not changed here, so this is non-blocking.

4. New types

  • No new named types.
  • boxKeyIsSet is an alias of hasValue. The alias is useful because it names the shared rule.
  • insertIfNew gets an inline { keep?: (value: string) => boolean } options type, which is fine.

5. General

  • The design is clean. Build's read and write now go through the same select and keep rules that the planner uses, which removes the class of disagreement that caused both bugs.
  • This fix exists only on box-integration, so it must survive later dev squashes (inline comment on manager.tsx).

Open items from earlier reviews

This PR addresses none of them, which is expected because they are out of scope:

  • the DEFAULT_EGRESS_BEDROCK_REGION fallback;
  • the empty .venv (MQ-6);
  • the unreported credential refresh failure and the silent AWS_PROFILE typo;
  • dev not applying the box.version rule;
  • the "before anything is written" comment on the assert;
  • the refusal message after remove;
  • the duplicated template files;
  • no start.py test;
  • the skipped telemetry targets (29d283d6);
  • no local-profile tests for the A2A, AG-UI and MCP templates;
  • the missing .box/<name>/local/profile.toml (#2859).

CI

  • Passing: Linux, Windows, Analyze, CodeQL and CodeBuild e2e.
  • e2e is skipped.
  • verify / macOS: still pending after 10 min (job queued; it has not started) when this review was posted.

The macOS runner queue has been slow, and the 5 s timeouts in the macOS screen tests are a known flake on the base. Neither of these blocks.

Comment thread src/core/project/envLocal.ts Outdated
const value = values[entry.key];
if (
keep === undefined ||
value === undefined ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking nit (silent failure, low risk): when keep is set and a key is in existingKeys (per KEY_LINE) but parseEnv did not produce it, value is undefined and the key is reported as skipped. build reads only written, so it would add the credential while the reserved variable stays blank. That is the bug this PR fixes, but now it happens without any message. I could only reach this case with odd input, such as a KEY= line inside another entry's multi-line quoted value, so it does not block. You could treat undefined like a rejected value when keep is given, or have build warn about a seeded key that ends up in skipped.

Comment thread src/core/project/envLocal.ts Outdated
written.push(entry.key);
}
if (replacements.size > 0) {
content = content.replace(ENV_ENTRY, (span, prefix: string, key: string) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking nit (comment accuracy): insertIfNew can now overwrite an existing key in place, but the class doc above (line 21) still says it "appends entries (never overwriting an existing key)". Please add "unless keep rejects its value" there, so the class doc matches the method doc.

Comment thread src/core/project/manager.tsx Outdated
if (edits.envLocal.length > 0) {
const { written } = await envLocal.insertIfNew([...edits.envLocal]);
// A blank entry is one the plan seeds, so it gets the seed rather than being skipped.
const { written } = await envLocal.insertIfNew([...edits.envLocal], { keep: boxKeyIsSet });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, for the squash plan: box-integration-development has neither boxKeyReads nor the keep option (dev's manager.tsx still calls insertIfNew([...edits.envLocal]) with no options, and reads .env.local in full). So this fix exists only on box-integration. Please add it to the list of fixes that a later dev squash of manager.tsx, envLocal.ts or boxNetworkWriters.ts must not overwrite.

box-integration now has 1b5b151, which replaces a box route's stored
key when the route's variable holds a different value. That also fixes
the blank reserved variable item, so this branch drops its own fix for
it and keeps only the decrypt fix, plus a test that a blank reserved
variable still gets its key when .env.local holds an unused
undecryptable entry.
@vvargu vvargu changed the title fix(build): decrypt only used .env.local keys and seed a blank reserved box key fix(build): decrypt only the .env.local keys box egress routes use Nov 20, 2026

@leo237 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of #2863 at abb4ddf8 (previously approved at 1a96f719)

Decision: APPROVE. The merge resolution is correct, and the PR still fixes what it says it fixes on the new base. The remaining findings are non-blocking.

Scope

  • The only new commit is abb4ddf8 Merge box-integration into box/fix-2845-review. Its second parent is the current box-integration tip, e2ac9d78, so the branch is up to date and has no conflicts.
  • The 72 base commits it brings in (the v1.x sync, #2854, #2857, #2859, #2860, #2862, #2865, #2866, #2867, #2870, #2871 and others) are not re-reviewed here.
  • The PR's net diff against box-integration is now 4 files and +119/-5: boxNetworkWriters.ts, boxProfileCredentials.ts, manager.tsx and manager.boxCredentials.test.ts.

Merge resolution (I compared the diff at 1a96f719 with the diff at abb4ddf8)

  • Kept unchanged:
    • boxKeyVariables
    • boxKeyReads, with its select and non-blank overrides
    • the manager.tsx read keyReads ? await envLocal.read(keyReads) : {}
    • the five undecryptable-entry tests, with the appendEnvLocal and storedKey helpers
  • Dropped, correctly: the blank-seeding half of the PR, which was the insertIfNew(..., { keep }) option, boxKeyIsSet, the two envLocal.test.ts tests and the two manager tests for a blank or kept reserved variable.
    • Base 1b5b151e ("Refresh a box route's stored key when its variable changes") replaced that design. Build now calls envLocal.upsert(...), and the planner's seed writes an entry whenever the route's value differs from the stored one. A blank AGENTCORE_CREDENTIAL_<ROUTE>= therefore gets replaced in place, so the case keep covered is still handled.
    • The old test "keeps a reserved variable that .env.local already sets" would now contradict the base's rotation behavior, so removing it is right.
    • Blank seeding is still tested at the manager level by "seeds a blank reserved variable when .env.local also holds an unused undecryptable entry". That test now goes through upsert's in-place branch.
  • Nothing from the base is reverted. The net diff only adds lines, apart from one import and the envLocal.read() call. The base's upsert and rotation path, the model-provider skip, the Secrets Manager skip, ENV_LOCAL_RELATIVE_PATH, #2862's dev env:// handling, #2866's per-runtime profiles and the #2860 telemetry code are all untouched.

Does the logic still fit the new base?

  • Key selection still matches the planner. seed still calls credentialEnvVarName(credential) only with credential = route. It still reads sources.envLocal only at variable and that reserved key. Routes whose variable an existing credential reserves still return before any lookup. So boxKeyVariables(routes) is exactly the set the planner reads, and a superset where routes are skipped.
  • Per-runtime networks (#2866): boxKeyReads and credentialsWriter both use uniqueRoutes(networks) across all runtimes, so they dedupe the same way. credentialsWriter is still the only writer that reads envLocal.
  • upsert does not undo the fix. It never decrypts the file. It re-encrypts only plaintext sensitive values, and LocalSecrets.encrypt skips values that start with enc:v1:. So an unused undecryptable entry passes through a seed write untouched.
  • The tests still fail without the fix. Without the select, envLocal.read() decrypts every entry, so the three "builds when ..." and "seeds ..." tests would throw. The two "stops on ..." cases guard against over-filtering. The tests use join and appendFile, with no hard-coded /, no : splitting, no POSIX modes and no shell spawns.

Earlier comments

  • The envLocal.ts:88 comment (a key that KEY_LINE sees but parseEnv does not is silently skipped by keep) and the envLocal.ts:106 comment (class doc says "never overwriting") no longer apply. The keep option is gone from this PR, and envLocal.ts is no longer in the diff.
  • The manager.tsx comment (this fix exists only on box-integration) still applies. box-integration-development (435b6ba1) has no boxKeyReads or boxKeyVariables. It still calls insertIfNew and does not read .env.local in build at all, so it does not have the bug, but it also does not have the fix. A later dev back-merge or squash that touches manager.tsx or boxNetworkWriters.ts must keep boxKeyReads. This is non-blocking.

New findings (non-blocking)

  1. An undecryptable reserved entry still stops a build, even when the shell supplies the route's key. Since 1b5b151e, a shell GITHUB_TOKEN=ghp_new replaces the stored AGENTCORE_CREDENTIAL_GITHUB anyway. But build still decrypts the stored value only to compare it, so a user who lost their encryption key cannot fix things by setting the variable and building again. The error tells them to "re-add the credential". Stopping is safe, so this is optional. If you want it, treat an undecryptable stored key as one that differs (and write the seed) when the route's variable has a value.
  2. The message is gone for a blank reserved variable. When upsert seeds a blank reserved variable in place, the key lands in updated, and build prints writing ... only for written. The planner prints updating ... only when the stored value is set. So a blank reserved variable is now seeded with no message. This is base behavior from 1b5b151e, not this PR's, and is cosmetic.

Plan

#2863 is not one of the plan PRs. It is the review follow-up for VV-2 (#2845, squash plan v2).

CI

All checks pass at abb4ddf8: verify on Linux, Windows and macOS, Analyze, CodeQL and CodeBuild e2e. e2e is skipped.

@tejaskash tejaskash left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, items 1 and 2 from the #2845 review are fixed: build now decrypts only the .env.local keys the box routes use, non-blank shell values override them, and a blank reserved variable gets seeded. Each part of the fix fails a test when reverted, and the #2845 fixes are still in place on box-integration. Requesting changes because the rest of that review isn't here yet, and there's one test gap (inline):

  1. The skip, not-adding and key-gone messages are still steps, not warnings (manager.tsx:1735 maps every edits.messages entry to type: "step").
  2. The five skip tests in boxProfileCredentials.test.ts (:207, :220, :232, :249, :260) could be one test.each.
  3. Fixtures still cast with as unknown as instead of going through the schema (boxProfileCredentials.test.ts:9, :157, :267).
  4. "a OAuthCredentialProvider" at boxProfileCredentials.ts:157.
  5. From the #2862 review, both still untouched: a reserved variable exported in the shell makes dev and deploy disagree with no message (boxProfileCredentials.ts:111), and a blank stored key is filled in with no message (:117-124).

If these go in a separate PR, that's fine, just link it here.

* route's `env://` variable, and the reserved variable of the credential named for the route.
* Build reads only these from `.env.local`, so an entry no route uses cannot stop it.
*/
export function boxKeyVariables(routes: readonly BoxEnvRoute[]): Set<string> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also selects variables the planner never reads: it returns early for a model-provider route (:142) and for a route whose variable an existing credential reserves (:139). So with [egress.openai] on env://OPENAI_API_KEY and an undecryptable OPENAI_API_KEY in .env.local, build still stops with "Could not decrypt a stored secret" for a route the planner would have skipped. Could this drop those routes with the same two conditions, or the doc comment above stop saying these are the variables the planner looks up? Separately, no test fails if the reserved variable is removed from the set. A manager test for a second build where the key is stored only under AGENTCORE_CREDENTIAL_GITHUB would cover it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8766abb. boxKeyVariables and the planner now use one predicate, boxRouteKeyHeldElsewhere. Build reads no key for a model-provider route or a reserved route. New manager tests cover an undecryptable OPENAI_API_KEY and a second build with the key only under AGENTCORE_CREDENTIAL_GITHUB. Each test fails when the fix is reverted.

expect(await storedKey(created.rootPath)).toBe("ghp_shell");
});

for (const [label, env] of [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small one: a for ... of loop with as const generates the two "stops on" tests. test.each([...]) matches the rest of the repo and drops the as const.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 57bfb0d. The two "stops on" tests now use test.each([...]), with no as const.

Comment thread src/core/project/boxNetworkWriters.ts Outdated
env: NodeJS.ProcessEnv,
): ReadEnvFileOptions | undefined {
const routes = uniqueRoutes(networks);
if (routes.length === 0) return undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small one: with no routes, select already rejects every name, so nothing is decrypted and the read returns {}. This guard and the | undefined return type can go, and manager.tsx:1692 becomes envLocal: await envLocal.read(boxKeyReads(networks, this.processEnv)).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in da4f1df. The guard and | undefined are removed. manager.tsx now calls envLocal.read(boxKeyReads(...)). A new test shows that a project with no box routes builds with an undecryptable entry in .env.local.

…nner skips

boxKeyVariables now drops a model-provider route and a route whose
variable an existing credential reserves, through the same predicate
planBoxProfileCredentials uses.
With no routes, select rejects every name, so the read decrypts nothing
and returns no entry.
…s warnings

planBoxProfileCredentials returns them in a separate warnings list, and
build emits them as warning events. Progress messages stay steps.
…n schema-parsed specs

The Secrets Manager fixture now uses a valid secretRef, which the old
cast hid. A payment credential row covers the article of the warning.
…s from the box route's key

Deploy provisions the reserved variable, but agentcore dev hands box the
route's variable. Build now warns when the two hold different keys.
@vvargu

vvargu commented Nov 21, 2026

Copy link
Copy Markdown
Author

Thanks. All five items are fixed in this PR:

  1. 3d64c00: the planner returns a separate warnings list. Build reports skip, not-adding and key-gone as warnings. Progress messages stay steps.
  2. and 3. b7afa00: the skip tests are one test.each, and all fixtures go through ProjectSpecSchema.parse. This found an invalid secretRef fixture, which is now fixed.
  3. 1794e59: the warning says "an OAuthCredentialProvider". A payment row keeps "a PaymentCredentialProvider".
  4. 3e19603: build warns when the shell's reserved variable and the route's variable hold different keys. 76bbfd0: build says when it fills in a blank stored key.

This branch also merges the current box-integration.

@leo237 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at 100b38a (was approved at abb4ddf). I looked at the PR's own commits 8766abb..76bbfd0 and the two merges of box-integration.

Merges. Both merges, 6857721 and 100b38a, match what git merge-tree produces automatically, so no conflicts were resolved by hand. box-integration (now including #2883, #2884 and #2885) is an ancestor of the head. git diff box-integration pr touches only the PR's 5 files, so no base change is reverted and no PR change is lost. ENV_LOCAL_RELATIVE_PATH, EnvLocalFile.upsert and the boxProfileCredentials checks are all still there. This branch merges into the base with no conflicts.

Addressed

  • Our earlier item (2), a blank stored key filled in with no message: 76bbfd0 adds the step "filling in the blank ... with the key in ...". It is tested in both the planner test and the manager test.
  • tejaskash's 5 items and 3 inline comments are all addressed. 3d64c00 adds a separate warnings channel, and manager.tsx emits those as type: "warning" events next to the network and IAM warnings, so they are still printed and nothing is swallowed. The build still stops where it should: the test.each "stops on an undecryptable entry that a route uses" cases still pass.
  • 8766abb: boxKeyVariables and the planner now share one check, boxRouteKeyHeldElsewhere. Tests cover an undecryptable OPENAI_API_KEY and a second build whose key is only under the reserved variable.
  • da4f1df: with no routes, select rejects every name, so fromFile is empty. LocalSecrets.decrypt then returns early before any key is loaded, so nothing is decrypted. The new test covers this.
  • The fixtures now go through the schema, and the skip tests are one test.each. The tests are CI-safe: no host paths, no splitting on :, no POSIX modes, no subprocesses, no network. The only account ID in the diff is the AWS documentation example ID.

The 3 affected test files pass locally (61 pass). CI is green: Linux, Windows and macOS verify, CodeQL, and e2e CodeBuild.

Still open (non-blocking)

  1. Our earlier item (1) is not addressed and has had no reply. If the stored AGENTCORE_CREDENTIAL_<NAME> cannot be decrypted, build still stops even when the shell sets the route's variable. boxKeyReads selects the reserved variable, and only the route's variable is in overrides, so the reserved entry is still decrypted. The fix we suggested earlier still works: if the route's variable is set in the shell, leave the reserved variable out of the read (or treat an undecryptable value as "different"), and seed it.
  2. Back-merge to box-integration-development is still needed.

New, non-blocking

  • boxKeyVariables still reads the variables of routes the planner skips with a warning: an OAuthCredentialProvider or PaymentCredentialProvider credential with the route's name, an API key credential that keeps its key in Secrets Manager (secretRef), a route that uses only a model-provider name or only a model-provider variable, an invalid name, a credential-field suffix, or a derived-variable clash. In each of these cases an undecryptable value for the route's variable in .env.local still stops the build, even though the planner never uses it. The doc comment does say "for each route it does not skip first", but the title of 8766abb says more than that ("a route the credential planner skips"). Two ways to fix it: have the planner itself report which variables it read, or move the remaining skip checks into the shared check. See the inline comment.
  • da4f1df now reads and parses .env.local on every build, even when there are no box routes. A .env.local that does not parse now stops such a build, where before this step skipped the file. It is probably fine because dev and deploy already parse that file, but this is a change in behavior.

Overlap with #2886 (0a84859)
#2886 adds the same two messages as 3e19603 and 76bbfd0, and the two branches conflict in boxProfileCredentials.ts (trial git merge-tree; manager.tsx, backends/cdk.ts and docs/box-local-testing.md conflict too). They behave the same way:

  • #2886 has an extra variable !== key guard. Here it makes no difference: if the route's variable is the reserved variable, value equals the exported key, so no warning is raised.
  • #2886 checks for a pending entry before the shell check. That only changes anything for two routes mapped to one credential, which uniqueRoutes already rules out in practice.

This PR's version is the better one: it reports the mismatch as a warning, which #2886 cannot do because it has no warnings channel and pushes the mismatch into messages (steps). This PR also has manager-level tests for both messages. I recommend that #2886 drop 0a84859 and take this version when it rebases.

Approving. None of the items above blocks this PR.

const reserved = new Set(credentials.flatMap(credentialEnvironmentVariableNames));
return new Set(
routes
.filter((route) => !boxRouteKeyHeldElsewhere(route, reserved))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this drops only the routes the planner skips silently. A route the planner skips with a warning (an OAuth or Payment credential with the route's name, a Secrets Manager secretRef API key, a model-provider name or variable used alone, an invalid name or suffix, a clash) still has variable and credentialEnvVarName(route) read and decrypted, so an undecryptable entry for it still stops the build. You could move those checks into the shared check, or have the planner return the variables it actually looked up.

@vvargu
vvargu requested a review from tejaskash November 21, 2026 02:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants