{"record":{"id":"da0f56ad01bee246","repo":"mvanhorn/last30days-skill","slug":"repo-dir-name-failed-for-topic-with-exit-re","errorCode":null,"errorMessage":"{repo_dir.name} failed for '{topic}' with exit {result.returncode}\\n{result.stderr.strip()}","messagePattern":"(.+?) failed for '(.+?)' with exit (.+?)\\\\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"skills/last30days/scripts/evaluate_search_quality.py","lineNumber":357,"sourceCode":"    if not engine.exists() or \"--json-profile\" in engine.read_text(encoding=\"utf-8\"):\n        cmd.append(\"--json-profile=raw\")\n    if search:\n        cmd.extend([\"--search\", search])\n    if quick:\n        cmd.append(\"--quick\")\n    if mock:\n        cmd.append(\"--mock\")\n    result = subprocess.run(\n        cmd,\n        cwd=repo_dir,\n        env=env,\n        capture_output=True,\n        text=True,\n        timeout=timeout_seconds,\n        check=False,\n    )\n    if result.returncode != 0:\n        raise RuntimeError(f\"{repo_dir.name} failed for '{topic}' with exit {result.returncode}\\n{result.stderr.strip()}\")\n    payload = json.loads(result.stdout)\n    # Shape guard: the evaluator compares raw Report fields. If the engine\n    # emitted the agent profile anyway (flag detection missed a future\n    # spelling), fail loudly instead of scoring empty ranked_candidates.\n    if \"schema_version\" in payload and \"ranked_candidates\" not in payload:\n        raise RuntimeError(\n            f\"{repo_dir.name} emitted the agent JSON profile; the evaluator \"\n            \"requires the raw Report (--json-profile=raw).\"\n        )\n    return payload\n\n\ndef create_worktree(rev: str) -> Path:\n    worktree_dir = Path(tempfile.mkdtemp(prefix=\"last30days-eval-\"))\n    subprocess.run(\n        [\"git\", \"worktree\", \"add\", \"--detach\", str(worktree_dir), rev],\n        cwd=REPO_ROOT,\n        check=True,","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/mvanhorn/last30days-skill/blob/c7460f6114449ddfe6ea3fc2f23c3d910c0e740c/skills/last30days/scripts/evaluate_search_quality.py#L339-L375","documentation":"run_repo() in evaluate_search_quality.py executes the last30days engine as a subprocess in a git worktree and raises RuntimeError when the child exits non-zero. The message includes the worktree name, the topic, the exit code, and the child's captured stderr, so the real cause is always in the appended stderr text.","triggerScenarios":"subprocess.run(cmd, cwd=repo_dir, capture_output=True, check=False) returning returncode != 0 — e.g. the engine hit a missing API key, a SystemExit(2) from flag validation (bad --search source, bad plan JSON), a network failure inside the engine, or an unhandled exception in the evaluated revision.","commonSituations":"Evaluating an old worktree revision that lacks a newer flag the harness passes; env vars (REDDIT credentials etc.) not propagated into the child env; the engine's Python version guard (error [5]) exiting 1 because the child resolves a different interpreter; worktree checkout of a broken commit.","solutions":["Read the stderr suffix of the message first — it names the engine's own error; fix that (key, flag, or code issue) rather than the harness.","Verify the env dict built for the child includes every credential the engine sources need for the topic's query type.","Reproduce manually: cd into the temp worktree path and run the same cmd printed from the harness.","If the revision is simply broken, pin the evaluator to a known-good rev or fix the commit under test."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    payload = run_repo(repo_dir, topic, mock=mock)\nexcept RuntimeError as exc:\n    # the trailing stderr names the engine's real failure\n    print(f'engine run failed: {exc}', file=sys.stderr)\n    raise SystemExit(1)","preventionTips":["Always read the stderr suffix — it contains the engine's own error message.","Propagate every required credential env var into the child env the harness builds.","Smoke-test each worktree revision with --mock before live benchmark runs."],"tags":["subprocess","evaluation","worktree","stderr"],"backgroundTag":null,"analyzedSha":"c7460f6114449ddfe6ea3fc2f23c3d910c0e740c","analyzedAt":"2026-08-15T03:34:49.540Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}