Skip to content

opus_tags: report CSV parser errors without a traceback - #7618

Open
coenflict wants to merge 1 commit into
ItsNotRexed:mainfrom
coenflict:fix/opus-tags-csv-errors
Open

coenflict wants to merge 1 commit into
ItsNotRexed:mainfrom
coenflict:fix/opus-tags-csv-errors

Conversation

@coenflict

Copy link
Copy Markdown

Claim for this new BUILD item: #7496 (comment)

An oversized field in either CSV raises csv.Error before tagging starts. Catch it at the CLI boundary so both inputs use the existing one-line diagnostic and exit code 2. The synthetic regression covers both flags and verifies that the Ogg fixture stays untagged.

Verification

Windows 11, Python 3.14.7, CPU only. No GPU, driver, or game files were used. AI-assisted (Codex).

  • Regression on the fetched origin/main base (1bd565fc2): both cases exited 1 with a traceback.
  • Regression after the fix: both cases exit 2 with one diagnostic and leave the fixture untouched.
  • python -m compileall -q make_game.py tools tests and python -I scripts/check_no_game_data.py tools/opus_tags.py tests/test_opus_tags.py pass.
  • Ran python -I tests/test_opus_tags.py: 20 of 21 pass. The existing Windows path assertion fails on the base and is addressed by tools, tests: fix six standalone unit tests that fail on Windows #7425.
  • Ran python -I tests/test_text_write_line_endings.py: the only findings are in unchanged files, tools/leonida_tui.py:753 and tools/wave_diff.py:373.

@slint6614-dev

Copy link
Copy Markdown
Contributor

Checked on Linux: merged onto main db9fef8 (merges cleanly).

  • python3 -B tests/test_opus_tags.py → OK
  • Negative control: with tools/opus_tags.py reverted to main and the new test kept, 3 tests fail, so the test catches the bug.
  • csv was already imported, so catching csv.Error needs no new import.
    Read the diff as well; it looks right to me.

@kapitche

Copy link
Copy Markdown
Contributor

Tested ecaa72d merged with main 976b3ec on Linux/Python 3.12.16: pass

Merge is clean (tools/opus_tags.py, tests/test_opus_tags.py). main now catches csv.Error alongside OSError/KeyError/ValueError, so an oversized CSV field gives the one-line "cannot read a CSV" error and exit 2 instead of a traceback.

  • python -I tests/test_opus_tags.py: Ran 21 tests, OK.
  • Negative control (tools/opus_tags.py restored from upstream/main): Ran 21 tests, FAILED (failures=2): test_cli_reports_an_oversized_csv_field_before_tagging for --names and --dialogue (1 != 2, traceback in the output), so the new test discriminates.

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.

3 participants