Repository navigation
fix: Bedrock credential chain works in the compiled binary - #1867
ralphstodomingo wants to merge 3 commits into
Conversation
… SDK's node entries The build's "browser" condition pulled `@smithy/core/config`'s browser stubs (`parseKnownFiles` is a Symbol). A build plugin resolves @aws-sdk, @smithy and @aws-crypto as Node does; the build refuses a binary with a stub. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VEmKQsV67ZmxvZP7buH4b5
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codex review logClaims this PR makes. A finding is a reproducible trace that breaks one of them.
Disclosed residuals (accepted, not findings):
Rounds
|
|
@codex review against the numbered claims and the disclosed residuals in the review-log comment on this PR: report only a reproducible trace that violates a numbered claim. Instances of the disclosed residuals are not findings. A round with no claim violation ends review. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
NotesThe delta from Previous Review Summaries (2 snapshots, latest commit a42594c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit a42594c)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (5 files)
NotesThe incremental delta now takes the stub list from Fix these issues in Kilo Cloud Previous review (commit c9feeae)Status: 2 Issues Found | Recommendation: Address before merge Overview
Core fix verified: the plugin resolves Issue Details (click to expand)SUGGESTION
Files Reviewed (5 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 43.1K · Output: 9.4K · Cached: 643.3K Review guidance: REVIEW.md from base branch |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
`build.ts` embeds `CHANGELOG.md`, builtin skills and migrations verbatim, so a text quoting `Symbol.for("node-only")` would have failed the release build. The guard now reads the modules listed in the build's metafile and names the offending ones.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VEmKQsV67ZmxvZP7buH4b5
|
@codex review against the numbered claims and the disclosed residuals in the review-log comment on this PR: report only a reproducible trace that violates a numbered claim. Instances of the disclosed residuals are not findings. A round with no claim violation ends review. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
A metafile input that doesn't resolve from the build's cwd was skipped, so a path mismatch would have passed the check without reading anything. It now fails and names the modules, and fails on an empty input list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VEmKQsV67ZmxvZP7buH4b5
|
@codex review against the numbered claims and the disclosed residuals in the review-log comment on this PR: report only a reproducible trace that violates a numbered claim. Instances of the disclosed residuals are not findings. A round with no claim violation ends review. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
dev-punia-altimate
left a comment
There was a problem hiding this comment.
🤖 Code Review — OpenCodeReview (Gemini) — 3 finding(s)
- 3 anchored to a line (posted inline when the comment stream is on)
- 0 without a line anchor
All findings (full text)
1. packages/opencode/script/aws-node-resolve.ts (L34)
[🟠 MEDIUM] Using at + 1 in indexOf leads to unnecessary overlapping substring checks. Since the stub string does not overlap with itself, advancing the search index by the length of NODE_ONLY_STUB is more efficient.
Suggested change:
for (let at = buf.indexOf(NODE_ONLY_STUB); at !== -1; at = buf.indexOf(NODE_ONLY_STUB, at + NODE_ONLY_STUB.length)) count++
2. packages/opencode/script/aws-node-resolve.ts (L44-L45)
[🟠 MEDIUM] For safety, it's recommended to defensively verify that metafile.inputs exists before passing it to Object.keys. If the metafile object returned by the build API is truthy but unexpectedly lacks the inputs property (e.g., due to Bun version changes or API anomalies), it will throw a TypeError.
Suggested change:
if (!metafile || !metafile.inputs) throw new Error("Bun.build returned no metafile, so the node-only stub check cannot run")
const inputs = Object.keys(metafile.inputs)
3. packages/opencode/script/build.ts (L671-L674)
[🟠 MEDIUM] Bun.build does not throw an error if the build fails. If the build fails (e.g., due to a TypeScript error), bundled.success will be false and bundled.metafile may be undefined. Passing an undefined metafile to nodeOnlyStubInputs will throw a generic "Bun.build returned no metafile..." error, which masks the actual underlying compilation error.
Consider checking bundled.success before inspecting the metafile to provide clear error messages, similar to how it is handled in your test fixtures.
Suggested change:
if (!bundled.success) {
for (const log of bundled.logs) console.error(log)
throw new Error(`Build failed for ${name}`)
}
// altimate_change start — refuse a build that bundled a node-only stub (aws-node-resolve.ts)
// A browser entry's stub in place of a node export fails only at run time, on the path that calls it (the
// Bedrock credential chain did).
const stubbed = nodeOnlyStubInputs(bundled.metafile)
| export function nodeOnlyStubCount(bytes: Uint8Array): number { | ||
| const buf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength) | ||
| let count = 0 | ||
| for (let at = buf.indexOf(NODE_ONLY_STUB); at !== -1; at = buf.indexOf(NODE_ONLY_STUB, at + 1)) count++ |
There was a problem hiding this comment.
[🟠 MEDIUM] Using at + 1 in indexOf leads to unnecessary overlapping substring checks. Since the stub string does not overlap with itself, advancing the search index by the length of NODE_ONLY_STUB is more efficient.
Suggested change:
| for (let at = buf.indexOf(NODE_ONLY_STUB); at !== -1; at = buf.indexOf(NODE_ONLY_STUB, at + 1)) count++ | |
| for (let at = buf.indexOf(NODE_ONLY_STUB); at !== -1; at = buf.indexOf(NODE_ONLY_STUB, at + NODE_ONLY_STUB.length)) count++ |
| if (!metafile) throw new Error("Bun.build returned no metafile, so the node-only stub check cannot run") | ||
| const inputs = Object.keys(metafile.inputs) |
There was a problem hiding this comment.
[🟠 MEDIUM] For safety, it's recommended to defensively verify that metafile.inputs exists before passing it to Object.keys. If the metafile object returned by the build API is truthy but unexpectedly lacks the inputs property (e.g., due to Bun version changes or API anomalies), it will throw a TypeError.
Suggested change:
| if (!metafile) throw new Error("Bun.build returned no metafile, so the node-only stub check cannot run") | |
| const inputs = Object.keys(metafile.inputs) | |
| if (!metafile || !metafile.inputs) throw new Error("Bun.build returned no metafile, so the node-only stub check cannot run") | |
| const inputs = Object.keys(metafile.inputs) |
| // altimate_change start — refuse a build that bundled a node-only stub (aws-node-resolve.ts) | ||
| // A browser entry's stub in place of a node export fails only at run time, on the path that calls it (the | ||
| // Bedrock credential chain did). | ||
| const stubbed = nodeOnlyStubInputs(bundled.metafile) |
There was a problem hiding this comment.
[🟠 MEDIUM] Bun.build does not throw an error if the build fails. If the build fails (e.g., due to a TypeScript error), bundled.success will be false and bundled.metafile may be undefined. Passing an undefined metafile to nodeOnlyStubInputs will throw a generic "Bun.build returned no metafile..." error, which masks the actual underlying compilation error.
Consider checking bundled.success before inspecting the metafile to provide clear error messages, similar to how it is handled in your test fixtures.
Suggested change:
| // altimate_change start — refuse a build that bundled a node-only stub (aws-node-resolve.ts) | |
| // A browser entry's stub in place of a node export fails only at run time, on the path that calls it (the | |
| // Bedrock credential chain did). | |
| const stubbed = nodeOnlyStubInputs(bundled.metafile) | |
| if (!bundled.success) { | |
| for (const log of bundled.logs) console.error(log) | |
| throw new Error(`Build failed for ${name}`) | |
| } | |
| // altimate_change start — refuse a build that bundled a node-only stub (aws-node-resolve.ts) | |
| // A browser entry's stub in place of a node export fails only at run time, on the path that calls it (the | |
| // Bedrock credential chain did). | |
| const stubbed = nodeOnlyStubInputs(bundled.metafile) |
🤖 Code Review — OpenCodeReview (Gemini) — 3 finding(s)
All findings (full text)1.
|
sahrizvi
left a comment
There was a problem hiding this comment.
Consensus review: approve. Panel: Claude (lead) and Codex (independent read-only pass, then a convergence round). Reviewed head 864b0e43cb against merge base 2ca1603b44.
What we ran
Binary (darwin-arm64, built with script/build.ts --single) |
Symbol.for("node-only") in binary |
Bedrock request with a fake profile in scratch AWS_CONFIG_FILE / AWS_SHARED_CREDENTIALS_FILE, endpoint on a closed local port |
|---|---|---|
| base | 14 | AWS credential provider failed: parseKnownFiles is not a function (#1866 reproduced) |
| head | 0 | ConnectionRefused on the local port: credentials resolved, request signed and sent |
- The TUI starts and renders the same from both binaries. An Anthropic provider aimed at a closed port fails the same way from both (connection error).
--versionand--helpwork. - Per-target
Bun.buildoptions: the only changes are the added plugin,metafile: trueand keeping the result. Nothing else changed. - Bundle module delta (from the binaries' source maps): only
@aws-sdk/*,@smithy/*and@aws-crypto/*modules move fromdist-es/ browser files todist-cjs. Also,@aws/lambda-invoke-storeis added (imported by@aws-sdk/core's node entry), andtslib/modulesis dropped (the ESM wrapper). Base bundled both the ESM and CJS copies of@smithy/coreand@aws-sdk/core; head bundles only CJS. External imports are identical (369 at base and at head), so no newnode:built-ins. - The check against the real metafile: 4,625 inputs, all relative to
packages/opencode(the cwd afterbuild.ts'schdir), none absolute, none virtual, none unreadable during the build. The scan reads about 62 MB in 125 ms. - A head build with the plugin removed fails and names the 7 browser-entry modules. A head build whose
CHANGELOG.mdquotes the marker passes. test/provider/aws-node-resolve.test.ts: 5 pass at head. With the plugin turned off, the "with awsNodeResolvePlugin" test fails. The test writes only under its own tmpdir, removes it, and passes scratch AWS files and a scratchHOME.test/providerplus the build and branding tests: 1,067 pass and 0 fail at head, against 1,062 and 0 at base (the 5 extra are the new tests).bun run typecheckpasses. The marker guard reports nothing to check, so we checked by hand: every edit tobuild.tssits insidealtimate_changemarkers, and the new files carry the new-file marker.
Remaining minor (does not block)
bun devstill hits the same error from source (inline comment). It predates this PR, affects developers only, and is safe to fix in a follow-up.
Two nits are in a separate PR comment. The disclosed residuals R1 to R3 are follow-ups, not blockers.
Upstream note for the merge path: upstream opencode removed packages/opencode, and its new packages/cli build no longer bundles with the browser condition, so there is no upstream fix to pull. Upstream closed the same bug in its binaries (anomalyco/opencode#31147) and in its dev scripts (anomalyco/opencode#40408) as not planned. This fix stays local to this fork.
| // and Smithy's packages resolve to their browser entries, where every node-only export is a stub: | ||
| // `@smithy/core/config` exports `parseKnownFiles = Symbol.for("node-only")`. `fromNodeProviderChain` reads the AWS | ||
| // config and credentials files through it, so every Amazon Bedrock request in a compiled binary failed with | ||
| // "parseKnownFiles is not a function", while source runs, which resolve the node entries, worked. |
There was a problem hiding this comment.
Minor (does not block: predates this PR, developer-only, fine as a follow-up). "Source runs, which resolve the node entries, worked" holds for bun run src/index.ts, but not for bun dev. Both package.json:9 and packages/opencode/package.json:16 run bun run --conditions=browser ./src/index.ts, and at runtime that condition picks @smithy/core's browser entries too.
Repro with this PR's own fixture and a fake profile in scratch files (AWS_CONFIG_FILE, AWS_SHARED_CREDENTIALS_FILE, AWS_PROFILE=fake, scratch HOME), run from packages/opencode:
bun run test/fixture/aws-credential-chain.tsprints{"accessKeyId":"fake-access-key-id"}.bun run --conditions=browser test/fixture/aws-credential-chain.tsthrowsTypeError: config.parseKnownFiles is not a function ... 'config.parseKnownFiles' is a Symbol.
So Bedrock is still broken under bun dev at this head. Suggest rewording the comment to "plain bun run source runs". A follow-up could fix the dev path, for example by preloading a runtime plugin that does the same resolution, or by dropping --conditions=browser from the dev scripts if the TUI no longer needs it. Upstream filed the same dev-script issue as anomalyco/opencode#40408.
|
Consensus review nits (Claude and Codex). Neither blocks the approval.
|
Issue for this PR
Closes #1866
Type of change
What does this PR do?
Every Amazon Bedrock request in a compiled binary failed with
AWS credential provider failed: parseKnownFiles is not a function. The release build bundles with thebrowserexport condition, which the Solid TUI needs. Under it,@smithy/core/configresolves to its browser entry, where node-only exports are stubs:parseKnownFilesisSymbol.for("node-only").fromNodeProviderChainreads profiles through it, so the chain threw before any request. Source runs use the node entry, which is why only binaries failed.script/aws-node-resolve.ts) resolves@aws-sdk/*,@smithy/*and@aws-crypto/*the way Node does. Every other package keeps thebrowsercondition.build.tsfails if any module it bundled containsSymbol.for("node-only"), and names the modules. It reads the build's metafile rather than the binary, becauseCHANGELOG.md, skills and migrations are embedded verbatim and could quote the marker.Main's binary had 14 such stubs, all in
@aws-sdk/core(client) and@smithy/core(config, retry and serde).How did you verify your code works?
altimate runagainst Bedrock with a fake profile in scratchAWS_CONFIG_FILEandAWS_SHARED_CREDENTIALS_FILE, and the endpoint on a closed local port. The real~/.awswas never read and no request reached AWS.--singlebinary and the released 0.12.12 both fail withparseKnownFiles is not a function … is a Symbol.build.tsregisters the plugin and runs the module check.Cost side effects
None.
Screenshots / recordings
Not a UI change.
Checklist
Codex review log: #1867 (comment)
🤖 Generated with Claude Code
https://claude.ai/code/session_01VEmKQsV67ZmxvZP7buH4b5
Summary by CodeRabbit