{"record":{"id":"b670238c145e4397","repo":"nikivdev/code","slug":"unable-to-determine-github-repo-origin-url-not-gi","errorCode":null,"errorMessage":"unable to determine GitHub repo (origin URL not GitHub, and `gh repo view` returned empty)","messagePattern":"unable to determine GitHub repo \\(origin URL not GitHub, and `gh repo view` returned empty\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":8566,"sourceCode":"        }\n    }\n\n    // Fallback: ask `gh` (works for GitHub Enterprise too if authenticated).\n    let repo = gh_capture_in(\n        repo_root,\n        &[\n            \"repo\",\n            \"view\",\n            \"--json\",\n            \"nameWithOwner\",\n            \"-q\",\n            \".nameWithOwner\",\n        ],\n    )\n    .context(\"failed to resolve GitHub repo for current directory\")?;\n    let repo = repo.trim();\n    if repo.is_empty() {\n        bail!(\n            \"unable to determine GitHub repo (origin URL not GitHub, and `gh repo view` returned empty)\"\n        );\n    }\n    Ok(repo.to_string())\n}\n\nfn sanitize_ref_component(input: &str) -> String {\n    let mut out = String::new();\n    let mut last_sep = false;\n    for ch in input.chars() {\n        if ch.is_ascii_alphanumeric() || ch == '-' || ch == '_' || ch == '.' {\n            out.push(ch);\n            last_sep = false;\n        } else if !last_sep {\n            out.push('-');\n            last_sep = true;\n        }\n    }","sourceCodeStart":8548,"sourceCodeEnd":8584,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L8548-L8584","documentation":"When determining which GitHub repository the current directory belongs to, the tool first tries parsing the origin URL; if that is not a GitHub remote it falls back to `gh repo view --json nameWithOwner`. This error is raised when both strategies fail: the origin URL isn't a GitHub URL and `gh repo view` returned an empty string. The tool cannot proceed without knowing the target repo.","triggerScenarios":"`resolve_github_repo()` gets an empty trimmed result from `gh repo view --json owner.name --jq .nameWithOwner`, i.e. origin is not a GitHub URL AND gh cannot infer the repo from the directory.","commonSituations":"Repo whose origin points to GitLab/Bitbucket/self-hosted git; detached directory with no remote; gh not authenticated in a way that lets it resolve `repo view` without a remote; running from a subdirectory of a non-git folder.","solutions":["Set the origin to a GitHub URL: `git remote set-url origin git@github.com:owner/repo.git`","Or make gh resolve it: `gh repo view` manually after `gh auth login`","Run the tool from inside the intended git repository working tree","Add explicit repo configuration to the tool if it supports specifying owner/repo"],"exampleFix":"// before\n$ git remote -v\norigin  https://gitlab.example.com/team/repo.git\nError: unable to determine GitHub repo ...\n// after\n$ git remote set-url origin https://github.com/owner/repo.git\n$ tool create-review  # resolves repo successfully","handlingStrategy":"validation","validationCode":"let url = git_remote_url(\"origin\").unwrap_or_default();\nlet is_github = url.contains(\"github.com\");\nlet gh_repo = Command::new(\"gh\")\n    .args([\"repo\", \"view\", \"--json\", \"nameWithOwner\",\n           \"--jq\", \".nameWithOwner\"])\n    .output()?;\nif !is_github && gh_repo.stdout.trim().is_empty() {\n    return Err(anyhow!(\"set a GitHub origin or authenticate gh first\"));\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = result {\n    if e.to_string().contains(\"unable to determine GitHub repo\") {\n        eprintln!(\"fix `git remote set-url origin <github url>` or `gh auth login`\");\n    }\n    return Err(e);\n}","preventionTips":["Ensure origin points at github.com before running GitHub-dependent flows","Authenticate gh (`gh auth login`) so `gh repo view` can resolve repos","Run the tool inside a git work tree with a configured remote","Validate `git remote -v` output in project setup scripts"],"tags":["github","gh-cli","remote","configuration"],"backgroundTag":"github-repo-unresolved","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}