{"record":{"id":"90bbb485fa649c97","repo":"paperclipai/paperclip","slug":"invalid-github-ref-options-ref","errorCode":null,"errorMessage":"Invalid GitHub ref '${options.ref}'.","messagePattern":"Invalid GitHub ref '(.+?)'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/install.ts","lineNumber":136,"sourceCode":"}\n\nexport async function resolvePublishedVersion(spec: string, runCommand: CommandRunner): Promise<string> {\n  const result = await runCommand(\n    \"npm\",\n    [\"view\", `paperclipai@${spec}`, \"version\", \"--json\", `--registry=${PUBLIC_NPM_REGISTRY}`],\n    { maxBuffer: 1024 * 1024 },\n  );\n  return parseResolvedVersion(result.stdout);\n}\n\nexport function resolveGitInstallRequest(options: InstallOptions): { repo: string; ref: string; pinned: boolean } | null {\n  if (!options.ref && !options.repo) return null;\n  if (!options.ref) throw new Error(\"--repo requires --ref.\");\n  if (options.canary || options.version) throw new Error(\"--ref cannot be combined with --canary or --version.\");\n  const repo = (options.repo ?? DEFAULT_GITHUB_REPO).trim();\n  const ref = options.ref.trim();\n  if (!/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/.test(repo)) throw new Error(`--repo must be an owner/name GitHub repository, received '${repo}'.`);\n  if (!ref || ref.startsWith(\"-\") || /[\\0\\r\\n]/.test(ref)) throw new Error(`Invalid GitHub ref '${options.ref}'.`);\n  return { repo, ref, pinned: /^[0-9a-f]{7,40}$/i.test(ref) };\n}\n\nasync function runGitHubCurl(\n  args: string[],\n  runCommand: CommandRunner,\n  options?: Parameters<CommandRunner>[2],\n): Promise<{ stdout: string; stderr: string }> {\n  // Anonymous GitHub requests are rate-limited per source IP (CI runners and\n  // corporate NAT exhaust the shared quota); honor an ambient token when present.\n  // The token travels via a curl --config file so it never appears in process args.\n  const token = process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN;\n  if (!token) return runCommand(\"curl\", args, options);\n  const configDir = fs.mkdtempSync(path.join(os.tmpdir(), \"paperclipai-gh-\"));\n  const configFile = path.join(configDir, \"headers\");\n  try {\n    fs.writeFileSync(configFile, `header = \"Authorization: Bearer ${token}\"\\n`, { mode: 0o600 });\n    return await runCommand(\"curl\", [\"--config\", configFile, ...args], options);","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/install.ts#L118-L154","documentation":"Sanity guard on the --ref flag: the value is URL-encoded into a GitHub API path, so a ref that is not a plausible branch/tag/commit identifier is rejected up front rather than producing a confusing 404 from the API.","triggerScenarios":"Thrown at cli/src/commands/install.ts:136 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid git ref (branch, tag, or commit SHA) to --ref."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}