Summary
The input store implementation assumes --input-store has a directory component and valid JSON. Relative filenames such as --input-store input.json, unreadable paths, or corrupt JSON can currently produce raw Python exceptions during generation.
Evidence
Observed locally:
python -m structkit.main generate --non-interactive --input-store input.json simple.yaml out
Traceback ...
FileNotFoundError: [Errno 2] No such file or directory: ''
Relevant code:
structkit/input_store.py:12-14 calls os.makedirs(os.path.dirname(input_file)); for input.json, os.path.dirname(...) is ''.
InputStore.load directly calls json.load, so corrupt JSON would raise json.JSONDecodeError as a traceback.
- These errors surface from
TemplateRenderer/FileItem construction rather than a clean CLI message.
Proposed fix
- Treat an empty dirname as current directory and avoid
os.makedirs('').
- Catch
json.JSONDecodeError and OSError with a clean InputStoreError message.
- Catch that domain error in commands/tools that construct
TemplateRenderer.
- Include the input-store path in error messages.
Acceptance criteria
--input-store input.json works and creates/uses ./input.json.
- Corrupt input-store JSON exits 1 with a clean message and no
Traceback.
- Permission/read/write errors for the input store include the path and exit 1 cleanly.
- Tests cover relative path, corrupt JSON, and unwritable/read-error path where practical.
Summary
The input store implementation assumes
--input-storehas a directory component and valid JSON. Relative filenames such as--input-store input.json, unreadable paths, or corrupt JSON can currently produce raw Python exceptions during generation.Evidence
Observed locally:
Relevant code:
structkit/input_store.py:12-14callsos.makedirs(os.path.dirname(input_file)); forinput.json,os.path.dirname(...)is''.InputStore.loaddirectly callsjson.load, so corrupt JSON would raisejson.JSONDecodeErroras a traceback.TemplateRenderer/FileItemconstruction rather than a clean CLI message.Proposed fix
os.makedirs('').json.JSONDecodeErrorandOSErrorwith a cleanInputStoreErrormessage.TemplateRenderer.Acceptance criteria
--input-store input.jsonworks and creates/uses./input.json.Traceback.