Skip to content

fix: update() with undefined/null id fails with not-found error - #1047

Merged
noam-honig merged 1 commit into
remult:mainfrom
drakeo338:claude/1001-fix
Oct 3, 2026
Merged

noam-honig merged 1 commit into
remult:mainfrom
drakeo338:claude/1001-fix

Conversation

@drakeo338

Copy link
Copy Markdown
Contributor

Fixes #1001.

Calling repo.update() with an undefined or null id crashed with a raw entity is undefined error instead of a clean not-found response, because update went straight to getEntityRef without checking the id first. The fix adds an explicit check that throws the same not-found error update already uses for an id that doesn't match a row, so a missing/undefined id now fails the same predictable way.

Verified locally: npm test in projects/tests went from 27 passed / 0 failed on main to 28 passed / 0 failed with this change, the new test asserting the not-found error for both undefined and null ids.

repo.update(undefined, {...}) fell through to getEntityRef(id, false),
which throws "entity is undefined" for a nullish argument regardless of
the throwException flag. Callers updating by an id that turned out to be
missing got that internal error instead of the 404 "id ... not found"
they get for any other missing row.

Check for a nullish id after the tracked-entity branch, so
update(anything, trackedInstance) keeps working, and throw the same
not-found error. Covers undefined and null on the backend and undefined
through the API proxy.

Fixes remult#1001
@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.44%. Comparing base (f3ff339) to head (c857774).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1047   +/-   ##
=======================================
  Coverage   87.44%   87.44%           
=======================================
  Files         108      108           
  Lines       17183    17184    +1     
  Branches     3842     3842           
=======================================
+ Hits        15025    15026    +1     
  Misses       2158     2158           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@noam-honig
noam-honig merged commit 96bc0cf into remult:main Oct 3, 2026
3 checks passed
@noam-honig

Copy link
Copy Markdown
Collaborator

@drakeo338 thanks

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.

Update by id on the backend when row not found - gives an entity is undefined error -instead of id not found

2 participants