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

Merged
hamdog0203 merged 2 commits from upstream-pr/625 into main 2026-11-28 22:22:11 +00:00
hamdog0203 commented 2026-11-24 10:10:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by hamdog0203 on 2026-11-24T10:10:49Z.


Claimed in the coordination issue as: DASH-HARDEN-CLI (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128321944)
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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5470148175 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/625). Originally posted by [hamdog0203](https://github.com/hamdog0203) on 2026-11-24T10:10:49Z. --- Claimed in the coordination issue as: DASH-HARDEN-CLI (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128321944) 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.
Dezmonius commented 2026-11-24 11:43:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Dezmonius on 2026-11-24T11:43:02Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7130455056 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/625#issuecomment-7130455056). Originally posted by [Dezmonius](https://github.com/Dezmonius) on 2026-11-24T11:43:02Z. --- 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: ```json [{"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 commented 2026-11-24 15:21:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by hamdog0203 on 2026-11-24T15:21:07Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7135878292 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/625#issuecomment-7135878292). Originally posted by [hamdog0203](https://github.com/hamdog0203) on 2026-11-24T15:21:07Z. --- > 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: > > ```json > [{"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 commented 2026-11-28 22:10:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T22:10:25Z.


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 #1274 and #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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246547524 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/625#issuecomment-7246547524). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T22:10:25Z. --- 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 #1274 and #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 commented 2026-11-28 22:22:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T22:22:18Z.


Merged after TheGeogeo's red/green check (https://github.com/ProjectLeonida/mandy/pull/625#issuecomment-7246547524) and a local re-check here: merged onto main 75df7d319 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246688451 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/625#issuecomment-7246688451). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T22:22:18Z. --- Merged after **TheGeogeo**'s red/green check (https://github.com/ProjectLeonida/mandy/pull/625#issuecomment-7246547524) and a local re-check here: merged onto `main` 75df7d319 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 in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!625
No description provided.