{"record":{"id":"a67afa5717f31dec","repo":"xai-org/grok-build","slug":"invalid-git-repository-structure","errorCode":null,"errorMessage":"Invalid git repository structure","messagePattern":"Invalid git repository structure","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-workspace/src/worktree/mod.rs","lineNumber":2193,"sourceCode":"\n#[derive(Debug)]\nstruct ApplyContext {\n    base_commit: String,\n    changed_files: Vec<GitFileChange>,\n}\n\n/// Get all files that differ between the main repo and the worktree.\nasync fn get_apply_context(worktree_path: &str) -> Result<ApplyContext> {\n    let wt_path = worktree_path.to_string();\n\n    tokio::task::spawn_blocking(move || {\n        let wt_repo = Repository::open(&wt_path)?;\n        let wt_head = get_head_commit(&wt_repo)?;\n\n        let main_git_dir = wt_repo.commondir().to_path_buf();\n        let main_repo_path = main_git_dir\n            .parent()\n            .ok_or_else(|| anyhow::anyhow!(\"Invalid git repository structure\"))?;\n        let main_repo = Repository::open(main_repo_path)?;\n        let main_head = get_head_commit(&main_repo)?;\n\n        let mut changed_files = Vec::new();\n        let mut seen_paths = HashSet::new();\n\n        // 1. Get committed changes: diff from main repo HEAD to worktree HEAD\n        let main_oid = Oid::from_str(&main_head)?;\n        let wt_oid = Oid::from_str(&wt_head)?;\n        let main_tree = wt_repo.find_commit(main_oid)?.tree()?;\n        let wt_tree = wt_repo.find_commit(wt_oid)?.tree()?;\n\n        let mut opts = DiffOptions::new();\n        let diff = wt_repo.diff_tree_to_tree(Some(&main_tree), Some(&wt_tree), Some(&mut opts))?;\n\n        for (idx, delta) in diff.deltas().enumerate() {\n            let path = delta\n                .new_file()","sourceCodeStart":2175,"sourceCodeEnd":2211,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-workspace/src/worktree/mod.rs#L2175-L2211","documentation":"Error \"Invalid git repository structure\" thrown in xai-org/grok-build.","triggerScenarios":"Thrown at crates/codegen/xai-grok-workspace/src/worktree/mod.rs:2193 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}