Skip to content

Reject non-array events and targets files with a one-line error - #88

Merged
EonHao merged 1 commit into
Juneo-Lab:mainfrom
kratos0718:fix-non-array-json-inputs
Nov 22, 2026
Merged

EonHao merged 1 commit into
Juneo-Lab:mainfrom
kratos0718:fix-non-array-json-inputs

Conversation

@kratos0718

Copy link
Copy Markdown
Contributor

Closes #71

Behavior

events-ingest and plan-recipe --mode explicit --targets looped directly over read_json(...). A number or string crashed with TypeError: '...' object is not iterable and a traceback, and an object was iterated by its keys, ending in "specification validation failed".

Both now read the file through a small read_json_array helper next to cli_errors, the same check evaluate-decisions does for its bindings, and exit 1 with one line:

$ echo 5 > events.json
$ uv run decision-forge events-ingest events.json --database events.sqlite
Error: Events file must be a JSON array

plan-recipe reports Error: Targets file must be a JSON array. The file is checked before ingest_events runs, so no database is created.

Validation

  • test_commands_reject_non_array_json_inputs covers both commands with number, string and object input (6 cases): exit code 1, exactly one Error: line, SystemExit rather than a traceback, and no events.sqlite. All 6 fail without the change.
  • pytest: 334 passed, 24 skipped. ruff check, ruff format --check and mypy src pass.
  • I didn't run mkdocs build --strict because mkdocs isn't in the default environment; no docs page changed.

Compatibility and data

No schema, API or data changes. Valid array inputs behave as before.

Checklist

  • A behavioral test fails without this change and passes with it (or this is docs/CI only).
  • ruff check, ruff format --check, mypy src, pytest --cov-fail-under=80, and mkdocs build --strict pass. (all but mkdocs, see above)
  • CHANGELOG.md is updated for user-visible changes; docs are updated for changed commands or contracts.
  • Examples remain fictional or appropriately licensed; no private material or credentials are included.

events-ingest and plan-recipe --targets looped directly over the parsed
JSON, so a number or string crashed with a TypeError traceback and an
object was iterated by its keys into a misleading validation failure.
Both now require a JSON array and exit 1 with one line, before any
database is created.

Closes Juneo-Lab#71
@kratos0718
kratos0718 requested a review from EonHao as a code owner November 17, 2026 12:31
@github-actions github-actions Bot added area/harness Workflow tasks, Harbor export, grading area/docs Site, README, and reference material labels Nov 17, 2026

@EonHao EonHao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @kratos0718. Approving.

What I checked:

  • Both call sites now read through read_json_array inside cli_errors, so a number, string, or object exits 1 with one Error: line instead of a traceback or a misleading validation failure.
  • events-ingest rejects the file before ingest_events runs, so a bad input no longer leaves an empty events.sqlite behind.
  • The six new cases fail on main and pass here. The full suite, Ruff, mypy, and mkdocs build --strict pass locally with this branch merged together with #86 and #87.

@EonHao
EonHao merged commit bfb63b1 into Juneo-Lab:main Nov 22, 2026
16 checks passed
EonHao added a commit that referenced this pull request Nov 22, 2026
@EonHao EonHao mentioned this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Site, README, and reference material area/harness Workflow tasks, Harbor export, grading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject non-array event and target files with an error instead of a traceback

2 participants