Skip to content

Constrain derived relations to their source model - #181

Draft
lippserd wants to merge 1 commit into
mainfrom
fix/derived-relation-source-identity
Draft

lippserd wants to merge 1 commit into
mainfrom
fix/derived-relation-source-identity

Conversation

@lippserd

Copy link
Copy Markdown
Member

I found this while adding lazy-loading regression coverage alongside the source/rule reverse-relation deprecation fix in Icinga/icinga-notifications-web#650.

With two Icinga DB sources and two matching rules, iterating $source->rule returns each rule twice. The reverse join matches both sources because it is constrained only by their shared type. This also inflates counts, breaks pagination, and allows a self filter to match a different source.

Constrain the reverse join to the originating model's complete primary key. Preserve relation-key filtering when the primary key is unavailable or incomplete. Keep hydrated binary keys from being transformed again as user input.

I have not found a way to reproduce this through the current Icinga Notifications Web UI and have not checked other modules for the same defect.

Derived relation queries constrain the reverse join only by the relation
keys. When those keys are nonunique, other source rows can join the same
targets. This duplicates results, inflates counts, breaks pagination, and
allows `self` filters to match a different source.

Constrain the reverse join by the complete primary key of the source
model when it is available. Preserve relation-key filtering for missing
or incomplete primary keys and avoid reapplying user-input transformations
to hydrated binary keys.
@cla-bot cla-bot Bot added the cla/signed label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant