fix: Bedrock credential chain works in the compiled binary

RA
2h ago
+198-2

Issue for this PR

Closes #1866

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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 the browser export condition, which the Solid TUI needs. Under it, @smithy/core/config resolves to its browser entry, where node-only exports are stubs: parseKnownFiles is Symbol.for("node-only"). fromNodeProviderChain reads profiles through it, so the chain threw before any request. Source runs use the node entry, which is why only binaries failed.

  • A build plugin (script/aws-node-resolve.ts) resolves @aws-sdk/*, @smithy/* and @aws-crypto/* the way Node does. Every other package keeps the browser condition.
  • The build refuses a stub. After each target compiles, build.ts fails if any module it bundled contains Symbol.for("node-only"), and names the modules. It reads the build's metafile rather than the binary, because CHANGELOG.md, skills and migrations are embedded verbatim and could quote the marker.
  • No dependency change.

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?

  • Ran altimate run against Bedrock with a fake profile in scratch AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE, and the endpoint on a closed local port. The real ~/.aws was never read and no request reached AWS.
    • Main's --single binary and the released 0.12.12 both fail with parseKnownFiles is not a function … is a Symbol.
    • This branch's binary gets past the credential chain, and the request fails only on the closed port.
  • Built all 8 release targets. Each binary has 0 stubs. linux-x64 went from 312.94MB to 312.88MB (64KB smaller).
  • The build's module check passes on linux-x64. With the plugin taken out, it fails and names the 7 browser-entry modules.
  • New tests bundle the real credential chain with the build's settings and run it offline against a fake profile. With the plugin, the profile's key resolves. Without it, the same chain fails with the user-facing error. The bundle also embeds a note quoting the marker, which the check doesn't count. Another test checks that build.ts registers the plugin and runs the module check.
  • Typecheck and the marker guard.

Cost side effects

None.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

Codex review log: https://github.com/AltimateAI/altimate-code/pull/1867#issuecomment-7282312468

šŸ¤– Generated with Claude Code

https://claude.ai/code/session_01VEmKQsV67ZmxvZP7buH4b5

Summary by CodeRabbit

  • Bug Fixes
    • Fixed AWS profile-based credential resolution in release builds, allowing applications to use credentials supplied through an AWS profile without errors caused by missing Node.js functionality.
  • Build Improvements
    • Release builds now detect bundled modules with unsupported Node.js-only behavior and report the affected modules, helping identify issues before release.