Reject unknown specific device identification objects - #2976
Merged
janiversen merged 2 commits intoJul 23, 2026
Merged
Conversation
janiversen
requested changes
Jul 23, 2026
janiversen
left a comment
Collaborator
There was a problem hiding this comment.
Please resolve conflicts with merged PRs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Return
ILLEGAL_DATA_ADDRESS (0x02)when an individual Read Device Identification request references an unknown object.Problem
Read Device Identification code
0x04performs individual access to a single object. The Modbus specification requires the server to return exception code0x02when the requested object ID does not match a known object.Previously,
ModbusDeviceIdentification.__getitem__()usedsetdefault()when reading an object. Accessing an unknown ID therefore inserted it into the identity data with an empty value.DeviceInformationFactorythen returned that value as a normal object, andReadDeviceInformationRequest.datastore_update()constructed a successful response containing a zero-length object instead of returning an exception.This also meant that simply reading an unknown object modified the device identity state.
Changes
Unknown identity lookups are now non-mutating. For individual access, reserved object IDs and objects that are not configured or have no available value return
ILLEGAL_DATA_ADDRESS (0x02). Existing stream-access behavior and valid individual object requests remain unchanged.Tests verify that a valid specific object is returned normally, unknown object
0x54and unavailable private object0xFEreturn exception code0x02, and reading an unknown object does not insert it into the identity dictionary.