fix(request): guard against null requestedBy to stop Discover crash and per-request 404s - #3463
Closed
jrogers512 wants to merge 1 commit into
Closed
fix(request): guard against null requestedBy to stop Discover crash and per-request 404s#3463jrogers512 wants to merge 1 commit into
jrogers512 wants to merge 1 commit into
Conversation
…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.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replacing
requestRepository.findOneOrFailwithfindOneplus an explicit 404 in the request routes, and guardingRequestCardagainst a nullrequestedBy, stops the Discover/request-list "Oops" crash and per-request errors that occur when a request'srequestedByIdFK is NULL (e.g. after a user is removed from the app, leaving an orphaned FK).The entity declares
requestedByas non-nullable, but orphaned rows still occur, so the code (which assumes non-null) must be hardened against it.requestData.requestedBy).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).Screenshots / Logs (if applicable)
N/A
Checklist:
pnpm buildpnpm i18n:extract