{"record":{"id":"64546e1bced1d087","repo":"tirth8205/code-review-graph","slug":"either-memory-dir-or-repo-root-required","errorCode":null,"errorMessage":"Either memory_dir or repo_root required","messagePattern":"Either memory_dir or repo_root required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"code_review_graph/memory.py","lineNumber":38,"sourceCode":"    repo_root: Path | None = None,\n) -> Path:\n    \"\"\"Save a Q&A result as markdown for re-ingestion.\n\n    Args:\n        question: The question that was asked.\n        answer: The answer/result.\n        nodes: Related node qualified names.\n        result_type: Type of result (query, review, debug).\n        memory_dir: Directory to save to. Defaults to\n            <repo>/.code-review-graph/memory/\n        repo_root: Repository root for default memory_dir.\n\n    Returns:\n        Path to the saved file.\n    \"\"\"\n    if memory_dir is None:\n        if repo_root is None:\n            raise ValueError(\n                \"Either memory_dir or repo_root required\"\n            )\n        memory_dir = (\n            repo_root / \".code-review-graph\" / \"memory\"\n        )\n\n    memory_dir.mkdir(parents=True, exist_ok=True)\n\n    # Generate filename from question\n    slug = re.sub(r\"[^\\w\\s-]\", \"\", question.lower())\n    slug = re.sub(r\"[\\s_]+\", \"-\", slug).strip(\"-\")[:60]\n    timestamp = int(time.time())\n    filename = f\"{slug}-{timestamp}.md\"\n\n    # Build markdown with YAML frontmatter\n    lines = [\n        \"---\",\n        f\"type: {result_type}\",","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/tirth8205/code-review-graph/blob/b58668751ab0c7670c078cf7cbd4d1f5b8e54f81/code_review_graph/memory.py#L20-L56","documentation":"save_result() requires a place to write: either an explicit memory_dir or a repo_root from which it derives <repo>/.code-review-graph/memory. Passing None for both leaves no destination, so it raises ValueError before any file IO.","triggerScenarios":"Calling memory.save_result(...) with both memory_dir=None and repo_root=None — e.g. when a CLI flag for --memory-dir is omitted and repo_root was never resolved.","commonSituations":"Optional CLI args defaulting to None; refactors that stopped threading repo_root through call sites; calling save_result in tests or scripts outside a repository context.","solutions":["Pass repo_root (usually Path.cwd() or the detected repo) and let it default to .code-review-graph/memory.","Or pass an explicit memory_dir path; it will be created if missing.","Audit call sites to ensure repo_root is resolved before save_result is invoked."],"exampleFix":"# before\nsave_result(result, memory_dir=None, repo_root=None)\n# after\nsave_result(result, repo_root=Path.cwd())\n# or\nsave_result(result, memory_dir=Path(\"/var/lib/crg/memory\"))","handlingStrategy":"validation","validationCode":"from pathlib import Path\nif memory_dir is None:\n    memory_dir = repo_root / \".code-review-graph\" / \"memory\" if repo_root else Path.cwd() / \".code-review-graph\" / \"memory\"","typeGuard":null,"tryCatchPattern":"try:\n    save_result(result, memory_dir=memory_dir, repo_root=repo_root)\nexcept ValueError:\n    save_result(result, repo_root=Path.cwd())  # fallback","preventionTips":["Resolve repo_root once at application startup and thread it to memory calls.","Default memory_dir explicitly in CLI argument parsing.","Add a unit test that save_result is never called with both destinations None."],"tags":["memory","config","missing-argument"],"backgroundTag":"missing-required-config-option","analyzedSha":"b58668751ab0c7670c078cf7cbd4d1f5b8e54f81","analyzedAt":"2026-08-28T13:19:08.966Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}