[PR #1500] dstorage_census: a wrong input is one ERROR line, not a traceback (DSTORAGE-CENSUS-WRONG-INPUT) #1529

Open
opened 2026-11-26 20:21:33 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1500
Author: @levi2m
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/dstorage-census-wrong-input


📝 Commits (1)

  • a5fbe68 dstorage_census: a wrong input is one ERROR line, not a traceback (DSTORAGE-CENSUS-WRONG-INPUT)

📊 Changes

2 files changed (+133 additions, -8 deletions)

View changed files

➕ tests/test_dstorage_census.py (+87 -0)
📝 tools/dstorage_census.py (+46 -8)

📄 Description

Claimed in the coordination issue as: DSTORAGE-CENSUS-WRONG-INPUT (claim)
Depends on: none
Fixes: none

What and why

tools/dstorage_census.py stopped with a Python traceback on a wrong input:

  • a trace path that does not exist (FileNotFoundError) or is a folder (IsADirectoryError);
  • a [rt] ds-request line with a missing field (KeyError: 'dest') or a malformed number (ValueError from int(..., 16)), for example a trace cut off mid-line.

Each is now one ERROR: line on stderr and exit code 2, like recomp_census (#1088). The census loop is unchanged: census() wraps it and turns a KeyError/ValueError into a TraceError that names the line number and the field. main() is split out of the __main__ block so it can be tested; output and exit code 0 for a good trace are unchanged.

Found by running every tools/*.py against a missing path, an empty file, a junk file and a folder. The other tools that traceback in that sweep (gbuffer_census, navmesh_cell_fit, root_spill_census) are covered by #952, so they are left alone.

Tested

  • python -I tests/test_dstorage_census.py: 7 tests OK (new file: a good trace, missing field, malformed number, missing path, folder, truncated line, exit 0 on a good trace). With the old tool the same file fails 5 of 7.
  • python -m compileall -q tools tests, tests/test_text_write_line_endings.py, tests/test_docs_cli_flags.py, tests/test_docs_links.py, tests/test_tool_stdout_encoding.py: OK.
  • scripts/check_no_game_data.py on both files: clean. Traces in the test are built by hand; no game files, no GPU.

GPUs tested: n/a (CPU-only tool and test)
AI-assisted: yes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1500 **Author:** [@levi2m](https://github.com/levi2m) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/dstorage-census-wrong-input` --- ### 📝 Commits (1) - [`a5fbe68`](https://github.com/ubiquitarianism/leonida/commit/a5fbe68937a87e351f7902df59eb9daa64a51a8e) dstorage_census: a wrong input is one ERROR line, not a traceback (DSTORAGE-CENSUS-WRONG-INPUT) ### 📊 Changes **2 files changed** (+133 additions, -8 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_dstorage_census.py` (+87 -0) 📝 `tools/dstorage_census.py` (+46 -8) </details> ### 📄 Description Claimed in the coordination issue as: DSTORAGE-CENSUS-WRONG-INPUT ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7150602137)) Depends on: none Fixes: none ### What and why `tools/dstorage_census.py` stopped with a Python traceback on a wrong input: - a trace path that does not exist (`FileNotFoundError`) or is a folder (`IsADirectoryError`); - a `[rt] ds-request` line with a missing field (`KeyError: 'dest'`) or a malformed number (`ValueError` from `int(..., 16)`), for example a trace cut off mid-line. Each is now one `ERROR:` line on stderr and exit code 2, like `recomp_census` (#1088). The census loop is unchanged: `census()` wraps it and turns a `KeyError`/`ValueError` into a `TraceError` that names the line number and the field. `main()` is split out of the `__main__` block so it can be tested; output and exit code 0 for a good trace are unchanged. Found by running every `tools/*.py` against a missing path, an empty file, a junk file and a folder. The other tools that traceback in that sweep (`gbuffer_census`, `navmesh_cell_fit`, `root_spill_census`) are covered by #952, so they are left alone. ### Tested - `python -I tests/test_dstorage_census.py`: 7 tests OK (new file: a good trace, missing field, malformed number, missing path, folder, truncated line, exit 0 on a good trace). With the old tool the same file fails 5 of 7. - `python -m compileall -q tools tests`, `tests/test_text_write_line_endings.py`, `tests/test_docs_cli_flags.py`, `tests/test_docs_links.py`, `tests/test_tool_stdout_encoding.py`: OK. - `scripts/check_no_game_data.py` on both files: clean. Traces in the test are built by hand; no game files, no GPU. GPUs tested: n/a (CPU-only tool and test) AI-assisted: yes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1529
No description provided.