Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion desloppify/app/commands/review/runner_process_impl/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def _output_file_has_json_payload(output_file: Path) -> bool:
if not output_file.exists():
return False
try:
payload = json.loads(output_file.read_text(encoding="utf-8", errors="replace"))
text = output_file.read_text(encoding="utf-8", errors="replace").lstrip()
payload, _ = json.JSONDecoder().raw_decode(text)
except (OSError, json.JSONDecodeError):
return False
return isinstance(payload, dict)
Expand Down
5 changes: 5 additions & 0 deletions desloppify/tests/review/test_runner_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ def test_valid_json_dict(self, tmp_path):
p.write_text('{"assessments": {}}')
assert _output_file_has_json_payload(p) is True

def test_valid_json_dict_with_codex_token_footer(self, tmp_path):
p = tmp_path / "out.json"
p.write_text('{"assessments": {}, "issues": []}\ntokens used\n1,234')
assert _output_file_has_json_payload(p) is True

def test_json_array_rejected(self, tmp_path):
p = tmp_path / "out.json"
p.write_text("[1, 2, 3]")
Expand Down