Skip to content

fix(request): guard against null requestedBy to stop Discover crash and per-request 404s - #3463

Closed
jrogers512 wants to merge 1 commit into
seerr-team:developfrom
jrogers512:fix/null-requestedby-handling
Closed

fix(request): guard against null requestedBy to stop Discover crash and per-request 404s#3463
jrogers512 wants to merge 1 commit into
seerr-team:developfrom
jrogers512:fix/null-requestedby-handling

Conversation

@jrogers512

@jrogers512 jrogers512 commented Sep 1, 2026

Copy link
Copy Markdown

Description

Replacing requestRepository.findOneOrFail with findOne plus an explicit 404 in the request routes, and guarding RequestCard against a null requestedBy, stops the Discover/request-list "Oops" crash and per-request errors that occur when a request's requestedById FK is NULL (e.g. after a user is removed from the app, leaving an orphaned FK).

The entity declares requestedBy as non-nullable, but orphaned rows still occur, so the code (which assumes non-null) must be hardened against it.

  • Fixes the Discover / request-list page crash (null dereference on requestData.requestedBy).
  • Fixes GET /api/v1/request/:id, retry, and status routes erroring/404ing for such requests.

How Has This Been Tested?

Confirmed against a live instance where requests 95/121/124 had requestedById = NULL:

  • GET /api/v1/request/{id} returns 200 after the fix (was 404 before).
  • Discover and request-list pages render without crashing.
  • Ran the repo's prettier check against both changed files - clean.

Screenshots / Logs (if applicable)

N/A

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

…d FK

Replace requestRepository.findOneOrFail with findOne + explicit 404 in GET,
DELETE, PUT, retry and status handlers, and use optional chaining on
request.requestedBy in permission checks. Guard RequestCard against a null
requestedBy so requests whose requestedById FK is NULL no longer crash the
Discover/request-list pages. This matches the runtime fix already deployed
to the 3.4.1 production instance after DB-orphan crashes.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jrogers512 jrogers512 changed the title Fix Discover crash and per-request errors when a request's requestedBy is null fix(request): guard against null requestedBy to stop Discover crash and per-request 404s Sep 1, 2026
@jrogers512 jrogers512 closed this Sep 1, 2026
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