{"record":{"id":"a7a29416f257d25a","repo":"abhigyanpatwari/GitNexus","slug":"gitnexus-analyze-failed-output-500","errorCode":null,"errorMessage":"gitnexus analyze failed: {output[-500:]}","messagePattern":"gitnexus analyze failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"eval/environments/gitnexus_docker.py","lineNumber":165,"sourceCode":"        cache_key = self._make_cache_key(repo_info)\n        cache_path = self.cache_dir / cache_key\n\n        if cache_path.exists():\n            logger.info(f\"Restoring GitNexus index from cache: {cache_key}\")\n            self._restore_cache(cache_path)\n            return\n\n        logger.info(\"Running gitnexus analyze...\")\n        skip_flag = \"--skip-embeddings\" if self.skip_embeddings else \"\"\n        result = self.execute({\n            \"command\": f\"cd /testbed && npx gitnexus analyze . {skip_flag} 2>&1\",\n            \"timeout\": self.gitnexus_timeout,\n        })\n\n        if result.get(\"returncode\", 1) != 0:\n            output = result.get(\"output\", \"\")\n            if \"error\" in output.lower() and \"indexed\" not in output.lower():\n                raise RuntimeError(f\"gitnexus analyze failed: {output[-500:]}\")\n\n        self._save_cache(cache_path, repo_info)\n\n    def _start_eval_server(self):\n        \"\"\"Start the GitNexus eval-server daemon in the background.\"\"\"\n        logger.info(\n            f\"Starting eval-server on {self.eval_server_host}:{self.eval_server_port}...\"\n        )\n\n        self.execute({\n            \"command\": (\n                f\"nohup npx gitnexus eval-server --port {self.eval_server_port} \"\n                f\"--host {self.eval_server_host} \"\n                f\"--idle-timeout 600 \"\n                f\"> /tmp/gitnexus-eval-server.log 2>&1 &\"\n            ),\n            \"timeout\": 5,\n        })","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/environments/gitnexus_docker.py#L147-L183","documentation":"Thrown by _index_repository() in eval/environments/gitnexus_docker.py after running `npx gitnexus analyze . [--skip-embeddings]` inside /testbed: if the command returns non-zero AND the output contains 'error' (case-insensitive) but NOT 'indexed', it raises with the last 500 chars of output. This heuristic avoids raising on analyze runs that printed 'error' as part of a successful 'N files indexed' summary.","triggerScenarios":"`npx gitnexus analyze . 2>&1` exits non-zero with an error-looking message (parse failure, OOM, missing language toolchain, permission error, grammar build failure). The raise fires only when 'indexed' is absent from the output.","commonSituations":"Missing C/C++ toolchain (python3/make/g++) so a required tree-sitter grammar source-builds fail; OOM in a constrained container; permission denied writing the index to .gitnexus/; corrupt prior index; out-of-memory embedding step (use --skip-embeddings in eval); repo with a language whose grammar is optional and skipped incorrectly.","solutions":["Read the last 500 chars of output in the message — it names the failing step (grammar build, embedding, parse error).","Ensure the image has the build toolchain: `apt-get install -y python3 make g++` for source-build fallback, or set GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1.","Increase container memory if embedding/parse died with a 137/OOM-kill signal.","Clear a corrupt prior index: `rm -rf .gitnexus` (or run gitnexus clean) before re-running analyze.","Reproduce locally with `npx gitnexus analyze . --skip-embeddings` on the same /testbed checkout to iterate faster."],"exampleFix":"# before\nresult = self.execute({'command': f'cd /testbed && npx gitnexus analyze . {skip_flag} 2>&1',\n                    'timeout': self.gitnexus_timeout})\n\n# after: pre-install toolchain in the image and pin gitnexus version\n# Dockerfile:\n#   RUN apt-get update && apt-get install -y python3 make g++\n#   RUN npm install -g gitnexus@<pin>\nresult = self.execute({'command': f'cd /testbed && gitnexus analyze . {skip_flag} 2>&1',\n                    'timeout': self.gitnexus_timeout})","handlingStrategy":"try-catch","validationCode":"# Preflight: dry-run analyze locally on the same /testbed to surface toolchain issues\n# Ensure required build tools exist in the image:\ndocker run --rm \"$IMAGE\" bash -lc 'which python3 make g++ || echo MISSING_TOOLCHAIN'\n# and clear any stale index:\ndocker run --rm -v \"$PWD:/testbed\" \"$IMAGE\" bash -lc 'rm -rf /testbed/.gitnexus'","typeGuard":"def is_analyze_failure(exc: RuntimeError) -> bool:\n    return 'gitnexus analyze failed' in str(exc)","tryCatchPattern":"try:\n    env._index_repository()\nexcept RuntimeError as e:\n    if is_analyze_failure(e) and 'Out of memory' in str(e):\n        env.skip_embeddings = True\n        env._index_repository()  # retry lighter\n    else:\n        raise","preventionTips":["Pre-install python3/make/g++ in the image and pin a gitnexus version.","Pass --skip-embeddings in eval to avoid the memory-heavy embedding step where possible.","Run `gitnexus clean` between runs to avoid corrupt-index false errors."],"tags":["eval","docker","gitnexus","analyze","toolchain","oom"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}