Skip to content

progress_dashboard: handle null comment authors, require --run-tests for --tests, and catch I/O and history errors (DASH-HARDEN-CLI) - #625

Merged
MoonEyes merged 2 commits into
ProjectLeonida:mainfrom
hamdog0203:fix/dash-harden-cli
Nov 28, 2026
Merged

MoonEyes merged 2 commits into
ProjectLeonida:mainfrom
hamdog0203:fix/dash-harden-cli

Conversation

@hamdog0203

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: DASH-HARDEN-CLI (#14 (comment))
Depends on: none

What and why

Fixes four CLI/error-handling gaps in tools/progress_dashboard.py:

  • collect_github() (--github --login) called c.get("author", {}).get("login") and c["body"].lower(), crashing with AttributeError when a coordination issue comment has "author": null (deleted/ghost GitHub account) or "body": null.
  • --tests REGEX without --run-tests was silently ignored instead of calling ap.error(...) like --login and --d3d-issue.
  • ci_test_files() ran before main()'s try ... except OSError block, letting directory/permission errors escape as raw tracebacks despite the _walk_error contract.
  • write_outputs() ran outside main()'s error handler, and corrupt or non-list history.json files (or UTF-8 BOM-prefixed ones) caused unhandled exceptions instead of a clean exit 2 (or loading cleanly with BOM stripped).

The fix

  • Safely handle null/missing author and body in collect_github().
  • Added _load_history() to strip UTF-8 BOM and raise ValueError on malformed JSON or non-list/malformed history.json.
  • Added ap.error("--tests requires --run-tests") and caught OSError/ValueError around ci_test_files() and write_outputs() in main() (exiting 2).
  • Added 5 regression tests in Hardening in tests/test_progress_dashboard.py.

Tested

Windows 11 (26200.9974), Python 3.12.10, CPU only, no game files.

  • python -I tests/test_progress_dashboard.py -v: 55/55 OK
  • Negative control (Hardening against main 21625bca8's tools/progress_dashboard.py): FAILED (failures=1, errors=4)
  • python -m compileall -q tools/progress_dashboard.py tests/test_progress_dashboard.py: exit 0
  • python -I scripts/check_no_game_data.py tools/progress_dashboard.py tests/test_progress_dashboard.py: exit 0
  • python -I tests/test_text_write_line_endings.py: 3/3 OK
  • git diff --check: clean

AI-assisted: yes.

…for --tests, and catch I/O and history errors (DASH-HARDEN-CLI)
@Dezmonius

Copy link
Copy Markdown
Contributor

Independent Windows 10 check at 151e300 with CPython 3.14.7. All five new hardening tests pass. The full file is 54/55 here. Its sole failure is the pre-existing path-scrubbing test with a Windows user-profile path containing a space (also fails at 21625bc).

The new history schema check still accepts a row with missing or null metrics, for example:

[{"content_hash":"old","metrics":null}]

With that file in the output directory, the CLI returns 0 and writes progress.html. Opening the generated page in Edge gives TypeError: Cannot convert undefined or null to object in trend() at Object.keys(h.metrics); the chart remains empty. A control history row with "metrics":{} renders without an error. I also confirmed that malformed JSON returns 2 and preserves the input file.

Could _load_history() require a metrics mapping for successful rows, or could the page handle absent metrics if older history files are meant to be accepted?

Local synthetic history only. AI-assisted (Codex).

@hamdog0203

Copy link
Copy Markdown
Contributor Author

Independent Windows 10 check at 151e300 with CPython 3.14.7. All five new hardening tests pass. The full file is 54/55 here. Its sole failure is the pre-existing path-scrubbing test with a Windows user-profile path containing a space (also fails at 21625bc).

The new history schema check still accepts a row with missing or null metrics, for example:

[{"content_hash":"old","metrics":null}]

With that file in the output directory, the CLI returns 0 and writes progress.html. Opening the generated page in Edge gives TypeError: Cannot convert undefined or null to object in trend() at Object.keys(h.metrics); the chart remains empty. A control history row with "metrics":{} renders without an error. I also confirmed that malformed JSON returns 2 and preserves the input file.

Could _load_history() require a metrics mapping for successful rows, or could the page handle absent metrics if older history files are meant to be accepted?

Local synthetic history only. AI-assisted (Codex).

Good catch, thanks for testing this on Windows!

Since every valid snapshot entry emitted by summary_line() always writes a string content_hash and a "metrics": {...} object, I tightened _load_history() in commit 3c2ad30d5 to require both isinstance(item.get("content_hash"), str) and isinstance(item.get("metrics"), dict).

Rows with missing metrics, "metrics": null, non-dict metrics, or non-string content_hash now exit cleanly with status 2 without modifying history.json or writing a broken progress.html. Added regression cases for all four shapes in Hardening.test_corrupt_non_list_and_bom_history_json.

Re-verified locally (tests/test_progress_dashboard.py: 55/55 OK; tests/test_text_write_line_endings.py: 3/3 OK; scripts/check_no_game_data.py: clean).

AI-assisted: yes

@TheGeogeo

Copy link
Copy Markdown
Contributor

Tested 3c2ad30d5 merged (no commit) with main aa918e5d9, Python 3.12.4, Windows 11, CPU only.

  • Green: python -I tests/test_progress_dashboard.py: 58 tests, 1 failure, test_default_repo_is_the_one_the_readme_clones. It fails the same way on plain main (the README no longer clones ubiquitarianism/leonida), so it is unrelated.
  • Red: with tools/progress_dashboard.py back to main, 5 of the new Hardening tests fail: 4 errors (test_github_login_skips_null_author_and_null_body, test_corrupt_non_list_and_bom_history_json, test_ci_test_files_oserror_exits_2_cleanly, test_write_outputs_oserror_exits_2_cleanly) and 1 failure (test_tests_flag_requires_run_tests).
  • The history check (content_hash str, metrics dict) matches what summary_line writes on main, so existing history.json files still load.
  • Merges cleanly together with progress_dashboard: hide a whole drive path that contains spaces (DASH-SCRUB-SPACES) #1274 and progress_dashboard: recover parse_lasttest after incomplete nested CTest logs (DASH-CTEST-INCOMPLETE-NESTED) #1256. With all three, 66 tests run, with only the same main failure.
  • check_no_game_data.py is clean.
  • Nit: the new except ValueError also wraps build(args, out_dir), so a ValueError from a bug in build becomes a one-line error: and exit 2 instead of a traceback.

No blocker from my side. AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit adfb382 into ProjectLeonida:main Nov 28, 2026
6 of 9 checks passed
@MoonEyes

Copy link
Copy Markdown
Collaborator

Merged after TheGeogeo's red/green check (#625 (comment)) and a local re-check here: merged onto main 75df7d3 without conflict, tests/test_progress_dashboard.py shows the same single failure with and without this PR (test_default_repo_is_the_one_the_readme_clones, already red on main: the README no longer clones ubiquitarianism/leonida), and every other test passes. CI no-game-data check is green.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants