Skip to content

FUND-2496 DRC Fix Owner Filter & LatestVertrouwelijkheidAanduiding Optimization#181

Open
Grabauskas wants to merge 5 commits into
mainfrom
feat/optimizing-drc-20260512
Open

FUND-2496 DRC Fix Owner Filter & LatestVertrouwelijkheidAanduiding Optimization#181
Grabauskas wants to merge 5 commits into
mainfrom
feat/optimizing-drc-20260512

Conversation

@Grabauskas
Copy link
Copy Markdown
Member

Prevents the planner from probing all 70M versie rows for tenant-scoped gebruiksrechten / object-information-object queries. Mirrors the pattern already used by Handlers/v1/5/GetAllEnkelvoudigInformatieObjectenQueryHandler.cs:181.

Pull Request

Description

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

Related Issues

Testing

  • Tests pass
  • Manual testing completed

Checklist

  • Self-review completed
  • Documentation updated (if needed)

Prevents the planner from probing all 70M versie rows for tenant-scoped
gebruiksrechten / object-information-object queries. Mirrors the pattern
already used by Handlers/v1/5/GetAllEnkelvoudigInformatieObjectenQueryHandler.cs:181.
Copilot AI review requested due to automatic review settings May 12, 2026 06:31
@Grabauskas Grabauskas added Bug Something isn't working Documenten API Related to Documenten (DRC) component labels May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves tenant-scoped authorization filtering in DRC “get all” handlers by adding an owner predicate to the inner EnkelvoudigInformatieObjectVersies EXISTS subquery (preventing cross-tenant false-positives and avoiding expensive probes over a very large versie table). In addition, it introduces and maintains a new LatestVertrouwelijkheidAanduiding field on EnkelvoudigInformatieObject plus an accompanying index/migrations, with unit tests covering both the authorization regression and the “latest VHA” persistence behavior.

Changes:

  • Add Owner == _rsin predicate to the versie Any(...) subquery in v1 handlers (and regression tests to prevent cross-tenant matches).
  • Add LatestVertrouwelijkheidAanduiding to EnkelvoudigInformatieObject, ignore it in request-to-domain mappings, and set it in create/update handlers.
  • Add migrations (column adoption + pagination/index include) and extend unit tests to cover the new “latest VHA” behavior.

Reviewed changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/OneGround.ZGW.Documenten.Web/Handlers/v1/GetAllObjectInformatieObjectenQuery.cs Adds owner predicate to versie EXISTS subquery for tenant-scoped auth filtering.
src/OneGround.ZGW.Documenten.Web/Handlers/v1/GetAllGebruiksRechtenQuery.cs Adds owner predicate to versie EXISTS subquery (currently contains a compile-breaking typo).
src/OneGround.ZGW.Documenten.Web/Handlers/v1/5/GetAllVerzendingenQueryHandler.cs Adds owner predicate to pagination EXISTS subquery for tenant-scoped auth filtering.
src/OneGround.ZGW.Documenten.DataModel/EnkelvoudigInformatieObject.cs Introduces persisted LatestVertrouwelijkheidAanduiding on the EIO entity.
src/OneGround.ZGW.Documenten.Web/Handlers/v1/CreateEnkelvoudigInformatieObjectCommandHandler.cs Sets LatestVertrouwelijkheidAanduiding when creating latest versie (v1).
src/OneGround.ZGW.Documenten.Web/Handlers/v1/1/CreateEnkelvoudigInformatieObjectCommandHandler.cs Sets LatestVertrouwelijkheidAanduiding when creating latest versie (v1.1).
src/OneGround.ZGW.Documenten.Web/Handlers/v1/5/CreateEnkelvoudigInformatieObjectCommandHandler.cs Sets LatestVertrouwelijkheidAanduiding when creating latest versie (v1.5).
src/OneGround.ZGW.Documenten.Web/Handlers/v1/1/UpdateEnkelvoudigInformatieObjectCommandHandler.cs Sets LatestVertrouwelijkheidAanduiding when updating latest versie (v1.1).
src/OneGround.ZGW.Documenten.Web/Handlers/v1/5/UpdateEnkelvoudigInformatieObjectCommandHandler.cs Sets LatestVertrouwelijkheidAanduiding when updating latest versie (v1.5).
src/OneGround.ZGW.Documenten.Web/MappingProfiles/v1/RequestToDomainProfile.cs Prevents clients from mapping LatestVertrouwelijkheidAanduiding into the domain model.
src/OneGround.ZGW.Documenten.Web/MappingProfiles/v1/1/RequestToDomainProfile.cs Same (v1.1).
src/OneGround.ZGW.Documenten.Web/MappingProfiles/v1/5/RequestToDomainProfile.cs Same (v1.5).
src/OneGround.ZGW.Documenten.DataModel/Migrations/20260511140530_adopt_latest_vertrouwelijkheidaanduiding.cs Adds/adopts the latest_vertrouwelijkheidaanduiding column and relaxes constraints/default.
src/OneGround.ZGW.Documenten.DataModel/Migrations/20260511140530_adopt_latest_vertrouwelijkheidaanduiding.Designer.cs EF migration snapshot updates for the new column.
src/OneGround.ZGW.Documenten.DataModel/Migrations/20260511150043_b_create_pagination_index_vha.cs Adds a covering index including latest_vertrouwelijkheidaanduiding (CONCURRENTLY).
src/OneGround.ZGW.Documenten.DataModel/Migrations/20260511150043_b_create_pagination_index_vha.Designer.cs EF migration snapshot updates for the new index.
src/OneGround.ZGW.Documenten.DataModel/Migrations/DrcDbContextModelSnapshot.cs Updates the overall model snapshot with the new column/index metadata.
src/Tests/OneGround.ZGW.Documenten.WebApi.UnitTests/HandlerTests/GetAllObjectInformatieObjectenQueryHandlerTests.cs Regression tests ensuring auth subquery cannot match versies from another owner.
src/Tests/OneGround.ZGW.Documenten.WebApi.UnitTests/HandlerTests/GetAllGebruiksRechtenQueryHandlerTests.cs Same regression coverage for gebruiksrechten handler.
src/Tests/OneGround.ZGW.Documenten.WebApi.UnitTests/HandlerTests/GetAllVerzendingenQueryHandlerTests.cs Same regression coverage for verzendingen pagination query; adds cache no-op helper for InMemory.
src/Tests/OneGround.ZGW.Documenten.WebApi.UnitTests/EnkelvoudigeInformatieHandlerTests/CreateEnkelvoudigInformatieObjectVersionsTests.cs Adds tests asserting LatestVertrouwelijkheidAanduiding is set on create (v1.1/v1/v1.5).
src/Tests/OneGround.ZGW.Documenten.WebApi.UnitTests/EnkelvoudigeInformatieHandlerTests/UpdateEnkelvoudigInformatieObjectVersionsTests.cs Adds tests asserting LatestVertrouwelijkheidAanduiding is set on update (v1.1/v1.5).
Files not reviewed (2)
  • src/OneGround.ZGW.Documenten.DataModel/Migrations/20260511140530_adopt_latest_vertrouwelijkheidaanduiding.Designer.cs: Language not supported
  • src/OneGround.ZGW.Documenten.DataModel/Migrations/20260511150043_b_create_pagination_index_vha.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/OneGround.ZGW.Documenten.Web/Handlers/v1/GetAllGebruiksRechtenQuery.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Grabauskas Grabauskas changed the title fix(drc): owner filter on versie subquery in two v1 handlers DRC: Fix Owner Filter & LatestVertrouwelijkheidAanduiding Optimization May 12, 2026
@Grabauskas Grabauskas changed the title DRC: Fix Owner Filter & LatestVertrouwelijkheidAanduiding Optimization FUND-2496 DRC Fix Owner Filter & LatestVertrouwelijkheidAanduiding Optimization May 12, 2026
Copy link
Copy Markdown
Contributor

@heuvea heuvea left a comment

Choose a reason for hiding this comment

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

I left some comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Documenten API Related to Documenten (DRC) component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants