Fix duplicate capture object resolution in readRowsByEntry - #55
Open
stefan-andrejevic wants to merge 1 commit into
Open
Conversation
Profile Generic entry-based selective access could resolve an incorrect column range when identical capture descriptors existed at different positions in the capture object list. readRowsByEntry resolved selected columns exclusively by descriptor values. When duplicate descriptors were present, a later occurrence could therefore resolve to the first matching capture object, causing columnIndex and columnCount to describe a different column range than the one selected by the caller. Preserve positional identity by first matching capture objects using their existing object and capture-object instances. Fall back to full descriptor matching for equivalent externally constructed objects to retain compatibility with existing callers. Also correct the object type comparison in the descriptor fallback, which previously compared the candidate object type with itself.
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
Fix Profile Generic entry-based selective access when identical capture
descriptors exist at different positions in the capture object list.
readRowsByEntrycurrently resolves selected columns by searchingpg.captureObjectsusing descriptor values. When duplicate descriptorsare present, a later occurrence can resolve to the first equivalent
capture object instead of its actual position.
This can produce an incorrect
columnIndexandcolumnCountin theselective access descriptor.
Problem
Profile Generic capture objects are positional. It is valid for
identical capture descriptors to occur at different positions in the
capture object list.
For example:
Positions 6 and 8 have equivalent descriptor values but represent
different positions in the Profile Generic capture object list.
When the capture object at position 8 is selected, descriptor-based
lookup finds the equivalent object at position 6 first.
As a result, a selection covering positions 1 through 8 can be encoded
as:
instead of:
The server then correctly returns the column range encoded in the
request, while the client still associates the response with the
originally selected columns. This can result in a mismatch between the
number of returned values and the number of expected columns.
Root Cause
readRowsByEntryconverts the supplied capture objects into thepositional
columnIndex/columnCountrepresentation required by theentry selector.
The existing implementation performs this conversion using descriptor
matching and stops at the first matching capture object.
Descriptor equality is not sufficient to preserve position when
multiple entries contain identical:
The existing comparison also contains:
which always evaluates to
Trueand therefore does not validate therequested object's type.
Solution
Resolve selected capture objects in two stages.
First, preserve the exact capture-object position when the supplied
objects originate from
pg.captureObjects:This distinguishes duplicate descriptors by their actual position in
the capture object collection.
If an identity match is not available, fall back to complete descriptor
matching. This preserves compatibility with callers that construct
equivalent capture-object tuples independently.
The fallback compares:
The object type comparison is also corrected to compare the candidate
against the requested capture object.
Behavior
Given identical descriptors at positions 6 and 8:
For a selection covering positions 1 through 8:
Compatibility
The change preserves the existing descriptor-based lookup as a fallback.
Existing callers that provide equivalent externally constructed capture
objects therefore continue to work as before, while selections using
objects from
pg.captureObjectsretain their exact positional identity.Scope
The change is limited to capture-object resolution in
GXDLMSClient.readRowsByEntry.It does not modify:
readRowsByRangereadRowsByRangeis not affected by this issue because its columnselection is serialized from the supplied capture descriptors rather
than being resolved back to positional
columnIndex/columnCountvalues.
Verification
The issue was reproduced with a Profile Generic containing identical
capture descriptors at different positions.
Before the change, selecting through the later duplicate produced a
shorter column range than requested.
After the change:
columnIndexandcolumnCountdescribe the intended range;