{"record":{"id":"84a83f5645df8d70","repo":"denisidoro/navi","slug":"invalid-link","errorCode":null,"errorMessage":"Invalid link","messagePattern":"Invalid link","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/common/git.rs","lineNumber":32,"sourceCode":"\npub fn meta(uri: &str) -> (String, String, String) {\n    let actual_uri = if uri.contains(\"://\") || uri.contains('@') {\n        uri.to_string()\n    } else if let Some((domain, route)) = uri.split_once('/') {\n        if domain.contains(\".\") {\n            format!(\"https://{domain}/{route}\")\n        } else {\n            // Users can pass name starting wirh a slash\n            let first_char = uri.chars().next();\n\n            if first_char == Some('/') {\n                format!(\"https://github.com{uri}\")\n            } else {\n                format!(\"https://github.com/{uri}\")\n            }\n        }\n    } else {\n        panic!(\"Invalid link\")\n    };\n\n    let uri_to_split = actual_uri.replace(':', \"/\");\n    let parts: Vec<&str> = uri_to_split.split('/').collect();\n    let user = parts[parts.len() - 2];\n    let repo = parts[parts.len() - 1].replace(\".git\", \"\");\n\n    (actual_uri, user.to_string(), repo)\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn test_meta_github_https() {\n        let (actual_uri, user, repo) = meta(\"https://github.com/denisidoro/navi\");\n        assert_eq!(actual_uri, \"https://github.com/denisidoro/navi\".to_string());","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/denisidoro/navi/blob/f7330b9ad5bd95b7d1a3c96d00e0a77deb589147/src/common/git.rs#L14-L50","documentation":"navi's `common::git::meta` parses a git URI into (url, user, repo). If the input contains no '://' scheme, no '@' (SSH style), and no '/' separator at all (so it can't be split into domain/route or user/repo), the parser has no way to interpret it and panics with \"Invalid link\". It's a hard panic, not a Result, because the function signature returns a tuple.","triggerScenarios":"Calling `git::meta(uri)` with a bare word that has no slash and no scheme/SSH marker, e.g. `meta(\"navi\")` or `meta(\"\")`. Any URI accepted must look like 'user/repo', 'github.com/user/repo', '/user/repo', 'https://host/user/repo', or 'git@host:user/repo.git'.","commonSituations":"Users typing just a repo name into `navi repo <name>` (intending a single-word shortcut), typos dropping the 'user/' prefix, shell variable interpolation yielding an empty string, or passing a local filesystem path without a slash.","solutions":["Provide the URI in one of the supported forms: 'user/repo', 'domain/user/repo', a full https URL, or an SSH URI","If you only know the repo name, prefix the GitHub user: 'denisidoro/navi' instead of 'navi'","Validate the URI shape before calling (contains '/' or '://' or '@') to avoid the panic","Upstream: convert the panic to a Result error for graceful handling"],"exampleFix":"// before\nlet (_, user, repo) = navi::common::git::meta(\"navi\");\n// after\nlet input = \"navi\";\nassert!(input.contains('/') || input.contains(\"://\") || input.contains('@'), \"Invalid link: pass user/repo\");\nlet (_, user, repo) = navi::common::git::meta(\"denisidoro/navi\");","handlingStrategy":"validation","validationCode":"fn is_valid_git_uri(uri: &str) -> bool {\n    uri.contains(\"://\") || uri.contains('@') || uri.contains('/')\n}\nif !is_valid_git_uri(input) {\n    eprintln!(\"Invalid link: expected user/repo, URL, or SSH URI\");\n    std::process::exit(1);\n}\nlet meta = navi::common::git::meta(input);","typeGuard":"fn looks_like_git_link(s: &str) -> bool {\n    !s.is_empty() && (s.contains(\"://\") || s.contains('@') || s.split_once('/').is_some())\n}","tryCatchPattern":"// meta panics rather than returning Result; isolate it\nlet result = std::panic::catch_unwind(|| navi::common::git::meta(uri));\nmatch result {\n    Ok((url, user, repo)) => println!(\"{} {} {}\", url, user, repo),\n    Err(_) => eprintln!(\"invalid link: {}\", uri),\n}","preventionTips":["Always pass user/repo or a full URL/SSH URI, never a bare repo name","Validate the URI shape before invoking meta","Trim shell input and guard against empty variables (${VAR:?msg})","Prefer shallow_clone with a validated URI"],"tags":["git","panic","invalid-input","uri-parsing"],"backgroundTag":"invalid-git-uri","analyzedSha":"f7330b9ad5bd95b7d1a3c96d00e0a77deb589147","analyzedAt":"2026-09-03T13:58:22.429Z","contentChangedAt":"2026-09-03T13:58:22.429Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}