{"record":{"id":"b3f50669b1fd3de3","repo":"Hmbown/CodeWhale","slug":"remote-url-is-empty-or-oversized","errorCode":null,"errorMessage":"remote url is empty or oversized","messagePattern":"remote url is empty or oversized","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":408,"sourceCode":"    )\n}\n\n/// Whether a git remote is safe to clone, show, or hand to a sandbox.\n///\n/// Rejects leading-dash injection (`--upload-pack=…`), embedded userinfo,\n/// and network remotes that do not classify as a supported forge. Local\n/// path remotes (offline fixtures) are allowed when they do not start\n/// with `-` and carry no userinfo.\npub fn safe_git_remote_url(raw: &str) -> bool {\n    validate_git_remote_url(raw).is_ok()\n}\n\n/// Classify and validate `job.remote_url` before any `git clone` or\n/// sandbox clone. Returns the trimmed URL on success.\npub fn validate_git_remote_url(raw: &str) -> Result<String> {\n    let url = raw.trim();\n    if url.is_empty() || url.len() > MAX_REMOTE_BYTES {\n        bail!(\"remote url is empty or oversized\");\n    }\n    if url.starts_with('-') {\n        bail!(\"remote url must not start with '-'\");\n    }\n    if url.chars().any(char::is_control) {\n        bail!(\"remote url contains control characters\");\n    }\n    if remote_has_userinfo(url) {\n        bail!(\"remote url must not embed userinfo\");\n    }\n    if looks_like_network_git_url(url) && classify_url(url).is_none() {\n        bail!(\"remote url is not a supported forge\");\n    }\n    Ok(url.to_string())\n}\n\n/// Display form of a remote: userinfo is never printed.\npub fn redact_remote_url(raw: &str) -> String {","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L390-L426","documentation":"validate_git_remote_url rejects a remote URL that, after trimming, is empty or exceeds MAX_REMOTE_BYTES. This is the first gate before any `git clone` (direct or sandboxed), ensuring the argument to git is present and bounded in size.","triggerScenarios":"Calling validate_git_remote_url, safe_git_remote_url, or clone_repository with an empty string, a whitespace-only string, or a URL longer than MAX_REMOTE_BYTES bytes.","commonSituations":"A config field `remote_url` left blank; an env var or CLI flag not set and defaulting to \"\"; a UI paste that only contained whitespace; a pathologically long URL pasted from a tool that embedded a whole command line.","solutions":["Set the remote URL to a real forge URL such as https://github.com/org/repo.git.","Trim the input and check it is non-empty before calling; surface a clear message to the user if blank.","Check the URL length is within MAX_REMOTE_BYTES and shorten it (drop embedded tokens/queries you do not need).","Fix the config/flag path that is producing an empty value (missing env var, unset default)."],"exampleFix":"// before\nlet url = std::env::var(\"REMOTE_URL\").unwrap_or_default();\nclone_repository(receipt, &url, path)?;\n// after\nlet url = std::env::var(\"REMOTE_URL\").unwrap_or_default();\nlet url = validate_git_remote_url(&url)?; // fails fast with the specific reason","handlingStrategy":"validation","validationCode":"fn remote_url_plausible(raw: &str) -> bool {\n    let url = raw.trim();\n    !url.is_empty() && url.len() <= MAX_REMOTE_BYTES\n}","typeGuard":"fn non_empty_bounded(s: &str, max: usize) -> Option<&str> {\n    let t = s.trim();\n    (!t.is_empty() && t.len() <= max).then_some(t)\n}","tryCatchPattern":"let url = match validate_git_remote_url(raw) {\n    Ok(u) => u,\n    Err(e) if e.to_string().contains(\"empty or oversized\") => {\n        eprintln!(\"please provide a remote URL (non-empty, < MAX_REMOTE_BYTES)\");\n        return;\n    }\n    Err(e) => return /* propagate */,\n};","preventionTips":["Make the remote URL a required, validated field in configs and CLIs.","Trim whitespace at input boundaries.","Reject empty values with a clear message instead of passing \"\" downstream.","Document MAX_REMOTE_BYTES and check long pastes before submission."],"tags":["validation","git","url"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}