Skip to content

Echo transaction id and device id in exception for undecodable request. - #3057

Merged
janiversen merged 1 commit into
pymodbus-dev:devfrom
sotomayorlucas:fix-3056-exception-ids
Oct 12, 2026
Merged

janiversen merged 1 commit into
pymodbus-dev:devfrom
sotomayorlucas:fix-3056-exception-ids

Conversation

@sotomayorlucas

Copy link
Copy Markdown
Contributor

Fixes #3056.

Since #3052, DecodePDU.decode() raises ModbusIOException itself, so the exception no longer carries the MBAP transaction id and device id that FramerBase.handleFrame() used to attach, and ServerRequestHandler.callback_data answers with 0/0. This catches the exception in handleFrame(), where tid and dev_id are already parsed, sets them, and re-raises.

Tests: test_rh_callback_data_undecodable_real_socket_frame and test_rh_callback_exc now also check the echoed transaction id and device id (both fail on dev without the change, pass with it). Full pytest run gives the same results with and without the change in my environment (the serial/TLS tests that fail here fail on dev too); ruff check, ruff format --check and pylint are clean on the changed files.

@janiversen janiversen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

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.

TCP server: exception response to an undecodable request has transaction id 0 and device id 0

2 participants