Skip to content

Fix missing argument in legacy message 3 log message - #4180

Open
kayaal34 wants to merge 2 commits into
Unidata:mainfrom
kayaal34:fix-msg3-log-args
Open

kayaal34 wants to merge 2 commits into
Unidata:mainfrom
kayaal34:fix-msg3-log-args

Conversation

@kayaal34

Copy link
Copy Markdown

Description Of Changes

Level2File._decode_msg3 logs 'Length of message 3 is %d instead of expected %d; ...' when it skips a legacy-format message 3, but only passes one argument. Formatting the record then fails with TypeError: not enough arguments for format string, so instead of the message, logging prints a --- Logging error --- traceback to stderr (and any handler at INFO level sees a broken record). This happens when reading the existing test files KVWX_20050626_221551.gz and KLTX20050329_100015.gz with INFO logging enabled.

The second argument is now the expected size (self.msg_hdr_fmt.size + msg_fmt.size, matching the 2 * msg_hdr.size_hw it is compared with), e.g. Length of message 3 is 1044 instead of expected 976; this is likely the legacy format. Skipping....

Added test_level2_legacy_msg3_log, which reads both files with INFO logging and checks the message formats. It fails on main with the TypeError and passes with the fix; tests/io/test_nexrad.py passes (177 tests) and ruff/flake8 are clean on the changed files.

Note: I found this with a static check (ruff PLE1206) and used Claude (an AI assistant) to help write the fix and test; I reviewed and ran them as described.

Checklist

  • Tests added

@kayaal34
kayaal34 requested a review from a team as a code owner October 21, 2026 14:41
@kayaal34
kayaal34 requested review from dcamron and removed request for a team October 21, 2026 14:41
Comment thread tests/io/test_nexrad.py Fixed

This branch has not been deployed

No deployments
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.

2 participants