Skip to content

Authenticate the install.sh preview fetch against the private website repo - #2499

Merged
malibio merged 1 commit into
mainfrom
issue-2382-website-token-fetch-fix
Sep 8, 2026
Merged

malibio merged 1 commit into
mainfrom
issue-2382-website-token-fetch-fix

Conversation

@malibio

@malibio malibio commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The release workflow's sync-install-script job failed on v0.2.8: fetchWebsiteInstallScript() in scripts/publish-install-script.ts fetched raw.githubusercontent.com anonymously, which 404s because NodeSpaceAI/nodespace-website is a private repo. WEBSITE_DEPLOY_TOKEN was only ever wired to the later git-push step, so this unconditional preview fetch (run inside main()'s Promise.all) threw before --push logic was reached.
  • WEBSITE_DEPLOY_TOKEN was also missing as a repo secret entirely; it has been added separately (via gh secret set) so the workflow can authenticate at all.
  • Fix: fetchWebsiteInstallScript now accepts a token and sends it as an Authorization header; main() passes WEBSITE_DEPLOY_TOKEN through and requires it unconditionally (a dry run against a private repo needs to read it too, not just push to it).
  • Closes Release build failed: v0.2.8 #2382 and Release build failed: v0.2.8 #2498 (duplicate report of the same failed run).

Test plan

  • bun run test baseline: 233 files / 4911 tests passed
  • bun run test:scripts: 378 tests passed, including publish-install-script.test.ts's existing pure-function coverage
  • Manually verified the fix against the real private repo: WEBSITE_DEPLOY_TOKEN=$(gh auth token) bun run scripts/publish-install-script.ts v0.2.8 now succeeds and prints the correct diff (previously 404ed)
  • bun run quality:fix clean (eslint, svelte-check, tsc, cargo fmt/clippy)
  • bun run test:all (pre-push gate) passed on retry — first attempt hit an unrelated flaky perf-timing test (architecture-benchmarks.test.ts, coverage-mode threshold), confirmed to pass in isolation

🤖 Generated with Claude Code

… repo (closes #2382, closes #2498)

nodespace-website is private, so fetchWebsiteInstallScript()'s anonymous
raw.githubusercontent.com request always 404ed regardless of
WEBSITE_DEPLOY_TOKEN (that token was only wired to the later push step).
The unconditional preview fetch in main()'s Promise.all threw before
--push logic ever ran, failing the release workflow's sync-install-script
job every time. Pass the token through as an Authorization header and
require it unconditionally, since even a dry run needs to read the
private repo.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Qk1Gu6aKeyK281gccKRfZr
@malibio

malibio commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

This is a small, well-targeted fix that correctly diagnoses and resolves the actual root cause of the sync-install-script CI failure: fetchWebsiteInstallScript() made an anonymous request against a now-private repo's raw content endpoint, which always 404s regardless of whether WEBSITE_DEPLOY_TOKEN was set — the token just wasn't being threaded through to that call site. The fix (accept an optional token, send it as an Authorization: token <token> header, require the token unconditionally in main() since a dry run against a private repo requires read auth too) is minimal, correctly scoped, and verified both by unit tests and a manual run against the real private repo. Cross-checking .github/workflows/release.yml's sync-install-script job confirms WEBSITE_DEPLOY_TOKEN was already wired into the step's env and the workflow always invokes with --push — so this fix closes the actual gap end-to-end, not just in theory.

I also checked the sibling script update-homebrew-cask.ts's fetchTapCaskVersion(), which does an anonymous raw.githubusercontent.com fetch with no token — at first glance this looks like an inconsistency, but NodeSpaceAI/homebrew-nodespace (that script's target) is confirmed public (gh repo view --json isPrivate → false), while NodeSpaceAI/nodespace-website is confirmed private (true). So the two scripts are each doing the right thing for their own repo's visibility — not a contradiction.

Review Type: Initial Review (no existing reviews/comments on the PR)

Requirements Check:

  • ✅ Issue Release build failed: v0.2.8 #2382 ("Release build failed: v0.2.8") — root cause identified and fixed; the CI job's env already had WEBSITE_DEPLOY_TOKEN wired, confirming the bug was purely the missing pass-through into fetchWebsiteInstallScript, which this PR fixes.
  • ✅ Issue Release build failed: v0.2.8 #2498 (duplicate report of the same failed run) — commit message contains closes #2498; bun run gh:view 2382/2498 confirms Release build failed: v0.2.8 #2498 is already State: closed.
  • ✅ No other acceptance criteria on either issue beyond "fix the failing release build" — verified via bun run gh:view on both.
  • ✅ PR description accurately reflects the diff (verified line-by-line against git diff origin/main...HEAD).

Findings

Critical Issues

None.

Suggested Improvements

  • 🟢 scripts/publish-install-script.ts:203-218 — Minor readability/DRY nit rather than a real issue: argument parsing (command/version-regex check) and the token-presence check are both early-exit validation blocks in main(), structured consistently with each other and with the rest of the file. No action needed — noting only because I looked for it per the review brief; the token requirement is correctly hoisted to a single validation point rather than being duplicated in pushInstallScriptUpdate, which just accepts token: string (non-optional) and trusts the caller.

  • 🟢 Auth scheme: Authorization: token <token> (classic scheme) is correct and is the safer/more universal choice over Bearer here — it's supported by both classic PATs and fine-grained PATs against raw.githubusercontent.com/the REST API, whereas Bearer support for fine-grained tokens has been a more recent, narrower rollout. No change needed; just confirming the choice is sound rather than an oversight.

Nitpicks

  • Nit: scripts/publish-install-script.ts:135 — const headers: HeadersInit = token ? { Authorization: \token ${token}` } : {}still supports a tokenless call (thetoken?: stringparameter stays optional), even thoughmain()now always supplies one and there's no remaining anonymous-fetch use case in this codebase. This is reasonable defensive design for an exported function (keepsfetchWebsiteInstallScriptindependently testable/callable without forcing a fake token), so I wouldn't block on it — just flagging that the optionality is now vestigial frommain()`'s perspective given the repo is unconditionally private.
  • Nit: An empty-string token (WEBSITE_DEPLOY_TOKEN="") would pass the !token falsy check as truthy-fails-to... actually "" is falsy in JS, so !token already catches it and exits with the clear error message. No gap here — mentioning only because the review brief asked about the empty-token edge case explicitly; it's already handled correctly by the existing falsy check, no .trim() needed.

Verification Performed

  • bun run test:scripts — 378/378 pass, including publish-install-script.test.ts's existing pure-function coverage (unchanged by this PR, as expected under the documented "no network-call tests" convention for this suite).
  • bun run quality:fix — clean (eslint, svelte-check, tsc, cargo fmt/clippy all pass with zero errors/warnings).
  • Confirmed .github/workflows/release.yml's sync-install-script job already passes WEBSITE_DEPLOY_TOKEN: ${{ secrets.WEBSITE_DEPLOY_TOKEN }} into the script's env and always invokes with --push — validating that this fix closes the real end-to-end gap.
  • Confirmed via gh repo view --json isPrivate: nodespace-website is private (true), homebrew-nodespace is public (false) — the differing auth treatment between this script and its sibling update-homebrew-cask.ts is correct, not an inconsistency.
  • Traced the error path of fetchWebsiteInstallScript: the thrown Error interpolates only res.status (an HTTP status code), never the token or headers — no leak risk on success or failure. Contrasted with pushInstallScriptUpdate, which does need (and has) token-scrubbing on its git-clone error path because it embeds the token directly in a git remote URL; fetchWebsiteInstallScript only ever puts the token in a header, so no equivalent scrubbing is needed there. This asymmetry is correct, not an oversight.
  • Confirmed test coverage convention: publish-install-script.test.ts's header comment documents that network-calling functions (checkReleaseAssets, fetchWebsiteInstallScript, pushInstallScriptUpdate) are intentionally excluded from this suite to keep it fast/deterministic/network-free. This PR's changes are entirely within those excluded network-calling functions and main() (not exported) — no new pure logic was introduced that would fall under the existing pure-function test pattern, so no test gap.

Recommendation: APPROVE

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

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.

Release build failed: v0.2.8

1 participant