Skip to content

fix(query): a _related or _referenced block on a schema with no table matches nothing - #4682

Merged
rubenvdlinde merged 1 commit into
developmentfrom
fix/referenced-missing-table
Oct 18, 2026
Merged

rubenvdlinde merged 1 commit into
developmentfrom
fix/referenced-missing-table

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

What

A _related or _referenced block that looks through a schema with no stored objects now matches nothing. Before this fix the request failed with HTTP 500.

That schema has no magic table yet (openregister_table_<register>_<schema> is created on first write). The EXISTS (SELECT 1 FROM <table> ...) subquery from #4678 ran against it anyway, and Postgres answered SQLSTATE[42P01] relation "openregister_table_23_281" does not exist. You can reproduce it on :8080 with GET /api/objects/dossiq/subsidieBeschikking?_referenced[subsidieAanvraag][subsidieaanvraag][case]=<uuid> (reqId RaFzCXqkY0sieghtIz3s).

How

RelatedRowQueryApplier::apply() now asks MagicTableHandler::existsTableForRegisterSchema() before rendering each block. The list and count paths already use this check (MagicMapper returns an empty result for a missing table), and it caches its answer. When the table is missing, the block adds 1 = 0, so the query answers the empty set. The block is never dropped, because a dropped block would answer the unfiltered set. The schema lookup still runs first, so an unknown or ambiguous schema is still refused.

Verified locally

  • New test RelatedRowQueryApplierTest::testAReferencedSchemaWithoutATableMatchesNothing. It fails on development and passes here. ReferencedRowFilterTest now stubs the table as present.
  • All of tests/Unit/Service/Query/ (40 tests) and MagicSearchHandlerTest pass.
  • phpcs and phpmd report nothing on the lines I changed.
  • One composer check:strict run: lint, phpcs, phpmd, psalm and phpstan pass. test:all ran 26,312 tests with 15 errors. These are the same AuditTrail and DraftRemovalAuditRow database tests that fail on development, because they need the full Nextcloud server.

AI-assisted: written with Claude Code.

… matches nothing

A schema that has never stored an object has no magic table yet, and the
EXISTS subquery against it answered HTTP 500 (relation does not exist).
The block now narrows to the empty set, the same answer the list path
gives for a missing table, using MagicTableHandler::existsTableForRegisterSchema.

Assisted-by: ClaudeCode:claude-opus-5-5
@rubenvdlinde
rubenvdlinde merged commit 1127e8a into development Oct 18, 2026
47 of 48 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 0327b91

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ❌
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
check-specs ✅
test-l10n ✅
test-l10n-parity ✅
format ✅
check-schema-l10n ✅
composer ✅ ✅ 173/173
npm ✅ ✅ 648/648
app:check-code ⏭️
info.xml ✅
REUSE ✅
lockfile sync ✅
PHPUnit ✅ 26287/26287 · 25 skipped
Newman ✅ 714/714
Playwright ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it locally with npx playwright test, or from the Actions tab on a branch with no open pull request into development.
Hydra gates ✅

Quality workflow — 2026-10-18 08:26 UTC

Download the full PDF report from the workflow artifacts.

WilcoLouwerse added a commit that referenced this pull request Oct 19, 2026
…-fixes-r2

Conflicts:
- OrganisationController: development's OrganisationUsageService (#4683
  usage report) and this branch's optional GrantChangeAuditor both join the
  constructor; the required service comes before the optional auditor.
- RelatedRowQueryApplier: development's missing-table guard and `*PREFIX*`
  table (#4682, #4684) kept; the bare table name still feeds the RBAC
  predicate's tableName (data-f3).
- OrganisationGrantManageGuardTest: both new constructor arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant