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

Open
github-bot wants to merge 2 commits from github-bot/gh-625 into main AGit
Owner

@⁠hamdog0203 on GitHub · 2026-11-24 10:10 UTC · original
hamdog0203:fix/dash-harden-cli → main · +126 −6 · 2 files · 2 commits · open

Claimed in the coordination issue as: DASH-HARDEN-CLI (#14)
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.

**@⁠hamdog0203** on GitHub · 2026-11-24 10:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/625) `hamdog0203:fix/dash-harden-cli` → `main` · +126 −6 · 2 files · 2 commits · open Claimed in the coordination issue as: DASH-HARDEN-CLI (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:12:33 +00:00
Author
Owner

@⁠Dezmonius on GitHub · 2026-11-24 11:43 UTC · original

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

**@⁠Dezmonius** on GitHub · 2026-11-24 11:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/625#issuecomment-7130455056) 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).
Author
Owner

@⁠hamdog0203 on GitHub · 2026-11-24 15:21 UTC · original

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

**@⁠hamdog0203** on GitHub · 2026-11-24 15:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/625#issuecomment-7135878292) > 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/625/head:github-bot/gh-625'
git switch 'github-bot/gh-625'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-625'
git switch 'github-bot/gh-625'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-625'
git switch 'github-bot/gh-625'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-625'
git switch 'main'
git merge --squash 'github-bot/gh-625'
git switch 'main'
git merge --ff-only 'github-bot/gh-625'
git switch 'main'
git merge 'github-bot/gh-625'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.