fix(opencomputer): bake gh auth wrapper into image at build time#849
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDuring snapshot image build, a shell wrapper is written to Changesgh Token Wrapper
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Terraform Validation Results
Pushed by: @ColeMurray, Action: |
Problem
In OpenComputer sandboxes the
ghCLI is unauthenticated and there is noGH_TOKEN/GITHUB_TOKENin the environment, so in-sandbox agents can't post PR review comments:This works on Modal.
Root cause
ghis authenticated by a thin wrapper at/usr/local/bin/gh(ahead of the real/usr/bin/ghonPATH) that mints a fresh token from the control plane via the credential helper'sgh-tokenaction and exports it asGH_TOKEN. That wrapper is installed at runtime bySandboxSupervisor._install_gh_wrapper()(packages/sandbox-runtime/.../entrypoint.py), which does a plainPath("/usr/local/bin/gh").write_text(...).sandboxuser and/usr/local/binis root-owned, so the write raisesPermissionError, which_install_gh_wrapper()swallows asOSErrorand logs atdebug. The wrapper is silently never installed, andghresolves to the bare, unauthenticated/usr/bin/gh.gitworks on OpenComputer because its credential-helper shim is baked into the image at build time (withsudo) — theghwrapper had no equivalent bake, only the root-only runtime install.Fix
Bake the
ghwrapper into the image at build time withsudo, immediately after the git credential-helper shim it mirrors. The body is byte-identical toGH_WRAPPER_BODYinentrypoint.py, so the runtime_install_gh_wrapper()sees a matching file and no-ops instead of failing to overwrite it.Validation
GH_WRAPPER_BODY.tscerrors on this file —@opencomputer/sdk/noderesolution and a pre-existing implicit-any at line 68 — are pre-existing and unrelated to this change.)Deploy note
Takes effect on the next OpenComputer base-snapshot rebuild; existing sessions are unaffected. The snapshot source-hash already includes
build-template.ts, so a Terraform-managed OC backend rebuilds automatically.Follow-ups (not in this PR)
/usr/local/binwrite behavior with the OpenComputer team._install_gh_wrapper()to be non-root-aware (fall back to a user-writable dir onPATH) and bump the silentdebugtowarn. Deferred for now.Summary by CodeRabbit
ghcan use available credentials without extra setup.