{"record":{"id":"8a552a5ee3390714","repo":"xai-org/grok-build","slug":"what-value-must-not-contain","errorCode":null,"errorMessage":"{what} '{value}' must not contain '..'","messagePattern":"(.+?) '(.+?)' must not contain '\\.\\.'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-workspace/src/session/git.rs","lineNumber":3093,"sourceCode":"        });\n    }\n    anyhow::bail!(\"merge of base ref '{base}' failed: {merge_out}\")\n}\n/// Reject a ref/branch value that could be parsed as a git option (leading `-`)\n/// or that carries whitespace/control characters or `..`. A boundary guard for\n/// client-influenced refs (notably `base_ref`) so they cannot be smuggled in as\n/// flags; combined with `--end-of-options` at each call site.\nfn ensure_ref_arg_safe(value: &str, what: &str) -> Result<()> {\n    anyhow::ensure!(!value.is_empty(), \"{what} must not be empty\");\n    anyhow::ensure!(\n        !value.starts_with('-'),\n        \"{what} '{value}' must not start with '-'\"\n    );\n    anyhow::ensure!(\n        !value.chars().any(|c| c.is_whitespace() || c.is_control()),\n        \"{what} '{value}' contains whitespace or control characters\"\n    );\n    anyhow::ensure!(\n        !value.contains(\"..\"),\n        \"{what} '{value}' must not contain '..'\"\n    );\n    Ok(())\n}\n/// Seed a committed `.gitignore` (secrets never enter git)\n/// when a fresh conversation branch is created and the repo has none. Distinct\n/// from [`seed_default_excludes`], which seeds the *local-only* `info/exclude`\n/// as a `stage_all` backstop; this file is meant to be committed, so it also\n/// protects explicit user commits and BYO-remote exports. Never overwrites an\n/// existing `.gitignore`.\nasync fn seed_default_gitignore(git_root: &Path) -> Result<()> {\n    let path = git_root.join(\".gitignore\");\n    if tokio::fs::metadata(&path).await.is_ok() {\n        return Ok(());\n    }\n    tokio::fs::write(&path, xai_grok_workspace_types::binding::DEFAULT_GITIGNORE).await?;\n    git_cli(git_root, &[\"add\", \"--end-of-options\", \".gitignore\"]).await?;","sourceCodeStart":3075,"sourceCodeEnd":3111,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-workspace/src/session/git.rs#L3075-L3111","documentation":"ensure_ref_arg_safe rejects ref values containing \"..\" — the git range syntax and a path-traversal-like sequence — so a single ref argument cannot be reinterpreted as a range expression (e.g. \"a..b\") or otherwise smuggle two refs into one argument. The library throws this to keep client-influenced ref arguments unambiguous.","triggerScenarios":"Passing a ref containing \"..\" (e.g. \"main..dev\", \"v1..v2\", or path-like \"../x\") into an operation that validates via ensure_ref_arg_safe (crates/codegen/xai-grok-workspace/src/session/git.rs:3093), where the parameter is meant to be a single branch/ref name.","commonSituations":"A caller reuses a range expression (meant for git log/diff ranges) as a branch argument; a path fragment leaks into a ref field; a user types \"origin/main..HEAD\" into a branch selector in a UI.","solutions":["Pass a single plain ref name; if you need a range, use the API meant for ranges rather than the branch/ref parameter.","Strip or reject \"..\" at your input boundary before calling the library.","Qualify ambiguous short names explicitly (e.g. \"refs/heads/main\") so no range interpretation is possible."],"exampleFix":"// before\nlet target = \"main..feature\"; // range past as branch\nmerge_to_main(&root, \"session\", target, false).await?;\n// after\nlet target = \"feature\"; // single ref only\nanyhow::ensure!(!target.contains(\"..\"), \"range syntax not allowed here\");\nmerge_to_main(&root, \"session\", target, false).await?;","handlingStrategy":"validation","validationCode":"if ref_name.contains(\"..\") { return Err(format!(\"'{}' is not a single ref (contains '..')\", ref_name)); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep range expressions and single-ref parameters in distinct API fields.","Use fully-qualified ref names (refs/heads/...) to avoid ambiguity.","Reject '..' early in UI/CLI input handling."],"tags":["git","validation","input-sanitization"],"backgroundTag":"invalid-git-ref","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}