Skip to content

fix(cli): skip blank GitHub tokens during git installs - #17997

Open
mrmg wants to merge 1 commit into
paperclipai:masterfrom
mrmg:fix/install-blank-github-token
Open

mrmg wants to merge 1 commit into
paperclipai:masterfrom
mrmg:fix/install-blank-github-token

Conversation

@mrmg

@mrmg mrmg commented Oct 28, 2026

Copy link
Copy Markdown

Thinking Path

  • Paperclip provides a CLI to install its code from GitHub.
  • Git-ref installs use an ambient GitHub token for private repositories.
  • An empty GH_TOKEN currently hides a valid GITHUB_TOKEN.
  • The request then runs without authentication and can fail with a 404.
  • This change selects the first non-blank token after trimming whitespace.
  • Private installs can use the configured fallback token, and anonymous failures explain the missing authentication.

Linked Issues or Issue Description

Closes #17634. Related: #13928 addresses git-ref package staging. Its diff does not fix blank-token selection. Issue-number and keyword searches found no dedicated fix PR.

What Changed

  • Trim token values and skip blank GH_TOKEN before trying GITHUB_TOKEN.
  • Add context to anonymous request failures while retaining the original error as the cause.
  • Test token precedence, absent and blank values, protected config-file permissions, cleanup, and anonymous failures.
  • Document token selection in the CLI guide.

Verification

  • pnpm --dir cli exec vitest run src/__tests__/install-command.test.ts src/__tests__/install-store.test.ts: 37 tests passed.

  • Before the fix, the expanded install-command suite had four failures in token-selection and anonymous-error cases. All now pass.

  • Tests use a fake command runner and inspect the real temporary config file. No live private-repository download was performed.

  • pnpm -r typecheck passed.

  • pnpm build passed.

  • Full pnpm test:run was attempted but interrupted after server suites failed during import with AI_InvalidArgumentError: baseURL must be a non-empty string. A focused server rerun reproduced the error. The runtime exports empty provider base URLs. Omitting empty *_BASE_URL variables from a focused rerun of server/src/__tests__/tool-access-service.test.ts allowed all 469 tests to pass. The full suite was not rerun to completion; full-suite acceptance is not claimed.

  • Tests ran on Linux against upstream cff331f6ca0a652b5e41641c68dfa5fa584c22ae with both independent fixes present. Each PR contains only its own fix.

Risks

Low risk. Non-blank GH_TOKEN keeps precedence. Tokens remain in a mode-0600 temporary curl config file and are removed after the request. Anonymous failures now have a contextual message; the original error is retained as the cause.

Model Used

OpenAI GPT-6 via Codex, with code execution and repository tools. The runtime does not expose a more specific deployment ID or context-window size.

Checklist

  • I have included a thinking path that traces from project context to this change
  • I have specified the model used (with version and capability details)
  • I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work
  • I have searched GitHub for duplicate or related PRs and linked them above
  • I have either (a) linked existing issues with Fixes: # / Closes # / Refs # OR (b) described the issue in-PR following the relevant issue template
  • I have not referenced internal/instance-local Paperclip issues or links (only public GitHub #NNN / github.com/paperclipai/paperclip URLs)
  • My branch name describes the change (e.g. docs/..., fix/...) and contains no internal Paperclip ticket id or instance-derived details
  • I have run tests locally and they pass
  • I have added or updated tests where applicable
  • I have updated relevant documentation to reflect my changes
  • I have considered and documented any risks above
  • All Paperclip CI gates are green
  • Greptile is 5/5 with no open P2s, recommendations, or follow-ups
  • I will address all Greptile and reviewer comments before requesting merge

CI and review checkboxes remain pending because those results are not yet available.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the existing non-blocking concern about hidden request error details.

Findings

  1. P2 Request errors lose their details ▶
Fix with agent prompt
### Issue 1
cli/src/commands/install.ts:155-158
When a Git install fails without a token, `runGitHubCurl` replaces the actual error with authentication advice. The CLI prints only `err.message`, so saving the original error in `cause` hides details such as a DNS failure, certificate error, or missing `curl`. Users may configure a token when that cannot fix the problem. Include the original error message alongside the token hint, and add a test for a non-authentication failure.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Git-ref installs now trim GitHub tokens and skip blank values before choosing a fallback.

  • Git-ref installs choose the first non-blank GitHub token.

Reviews (2) · Last reviewed commit: "fix(cli): skip blank GitHub tokens durin..." · Reviewed by Greptile

Comment on lines +155 to +158
throw new Error(
"GitHub request failed without authentication. Set GH_TOKEN or GITHUB_TOKEN for private repositories or higher rate limits.",
{ cause },
);

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.

P2 Request errors lose their details

When a Git install fails without a token, runGitHubCurl replaces the actual error with authentication advice. The CLI prints only err.message, so saving the original error in cause hides details such as a DNS failure, certificate error, or missing curl. Users may configure a token when that cannot fix the problem. Include the original error message alongside the token hint, and add a test for a non-authentication failure.

Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/commands/install.ts
Line: 155-158

Comment:
**Request errors lose their details**

When a Git install fails without a token, `runGitHubCurl` replaces the actual error with authentication advice. The CLI prints only `err.message`, so saving the original error in `cause` hides details such as a DNS failure, certificate error, or missing `curl`. Users may configure a token when that cannot fix the problem. Include the original error message alongside the token hint, and add a test for a non-authentication failure.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@commitperclip

commitperclip Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@greptileai

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.

An empty GH_TOKEN hides a usable GITHUB_TOKEN during git install

1 participant