Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

fix: guard against null return from find() in PATCH path of updateFromArray#1346

Merged
bbrands02 merged 1 commit into
developmentfrom
fix/patch-null-guard-object-service-mapper-adapter
Apr 24, 2026
Merged

fix: guard against null return from find() in PATCH path of updateFromArray#1346
bbrands02 merged 1 commit into
developmentfrom
fix/patch-null-guard-object-service-mapper-adapter

Conversation

@bbrands02

Copy link
Copy Markdown
Contributor

Summary

objectService->find() returns ?ObjectEntity (nullable). In updateFromArray(), when $patch === true, the result was dereferenced unconditionally via $existing->getObject(). If the target object does not exist — unknown ID, wrong register/schema scope, or RBAC denial — find() returns null and the call produces a fatal TypeError, surfacing as an unhandled 500.

The fix adds an explicit null check immediately after find() and throws ValidationException with a clear message. Using a uniform message for both "not found" and "not accessible" also prevents ID enumeration through differing error signatures.

Reported in code review by @WilcoLouwerse.

Test plan

  • PATCH an object with a valid ID in the correct register/schema scope — verify normal update behaviour is unchanged
  • PATCH an object with an ID that does not exist — verify a ValidationException is thrown (no unhandled 500)
  • PATCH an object with an ID that exists but in a different register/schema scope — verify a ValidationException is thrown rather than a fatal TypeError
  • Run existing unit and integration tests for ObjectServiceMapperAdapter and confirm no regressions

🤖 Generated with Claude Code

…mArray

objectService->find() returns ?ObjectEntity. When the target object does
not exist — unknown ID, wrong register/schema scope, or RBAC denial —
find() returns null and the unconditional getObject() call produces a
fatal TypeError, surfacing as an unhandled 500.

Add an explicit null check and throw ValidationException so callers
receive a clear, actionable error instead of a cryptic fatal. Using a
uniform error message for both "not found" and "not accessible" also
prevents ID enumeration through differing error signatures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ f1ddfaa

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 147/147
npm ✅ 599/599
PHPUnit ⏭️
Newman ⏭️
Playwright ⏭️

Quality workflow — 2026-04-24 11:52 UTC

Download the full PDF report from the workflow artifacts.

@bbrands02 bbrands02 merged commit 3fbae7a into development Apr 24, 2026
18 of 20 checks passed
@bbrands02 bbrands02 deleted the fix/patch-null-guard-object-service-mapper-adapter branch April 24, 2026 12:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants