mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 09:45:24 -04:00
fix(cookbook): locate cookbook_state.json via DATA_DIR, not hardcoded /app/data (#3332)
Three call sites hardcoded Path("/app/data/cookbook_state.json"), which only
exists in Docker; on a native run the real path is <repo>/data, so the state
file looked missing and cookbook serve-state was silently ignored. Two others
used os.environ.get("DATA_DIR", "data") (a relative fallback, since DATA_DIR is
never set as an env var). Route all five through core.constants.DATA_DIR so the
path is consistent and absolute on both Docker and native.
Part of #3331.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
9c90f62657
commit
505d8bae5a
@@ -0,0 +1,29 @@
|
||||
"""Guard: cookbook_state.json must be located via DATA_DIR, not hardcoded /app/data
|
||||
(which breaks native runs) or a relative os.environ fallback."""
|
||||
import pathlib
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
FILES = [
|
||||
"src/cookbook_serve_lifecycle.py",
|
||||
"src/builtin_actions.py",
|
||||
"routes/codex_routes.py",
|
||||
"routes/cookbook_routes.py",
|
||||
]
|
||||
|
||||
|
||||
def test_no_hardcoded_app_data_cookbook_state():
|
||||
for rel in FILES:
|
||||
text = (ROOT / rel).read_text(encoding="utf-8")
|
||||
for ln in text.splitlines():
|
||||
if ln.strip().startswith("#"):
|
||||
continue
|
||||
assert "/app/data/cookbook_state" not in ln, f"{rel}: hardcoded /app/data: {ln.strip()}"
|
||||
assert 'os.environ.get("DATA_DIR"' not in ln, f"{rel}: relative DATA_DIR env fallback: {ln.strip()}"
|
||||
|
||||
|
||||
def test_cookbook_state_uses_datadir_constant():
|
||||
# Each file that references cookbook_state.json should import the DATA_DIR constant.
|
||||
for rel in FILES:
|
||||
text = (ROOT / rel).read_text(encoding="utf-8")
|
||||
if "cookbook_state.json" in text:
|
||||
assert "from core.constants import DATA_DIR" in text, f"{rel}: missing DATA_DIR import"
|
||||
Reference in New Issue
Block a user