-
-
Notifications
You must be signed in to change notification settings - Fork 580
fix(media-request-subscriber): prevent mediald nullification from cascade saves #2356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(media-request-subscriber): prevent mediald nullification from cascade saves #2356
Conversation
|
Related to #2316 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes an intermittent TypeORM relation-mapping issue that could create media_request rows with a NULL mediaId, leading to orphaned requests and frontend crashes when request.media is missing.
Changes:
- Adds an explicit
@JoinColumn({ name: 'mediaId' })to theMediaRequest.mediarelation. - Removes the separate
mediaIdcolumn/property and stops manually settingmediaIdduring request creation, relying on the relation mapping instead.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged. |
63b6433 to
a74b313
Compare
a74b313 to
c5479c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
03ad825 to
d78a996
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7de1b36 to
902a69c
Compare
Fixes intermittent NULL mediaId foreign key on media_request records byadding explicit @joincolumn decorator to the media relation. Without this,TypeORM's implicit FK mapping was unreliable, causing orphaned requeststhat would crash the frontend when accessing user profiles. Also removes the redundant @column decorator for mediaId which conflicted withthe relation, and removes explicit mediaId assignments in the constructorwhich are now handled correctly by TypeORM through the relation.
…cade saves The mediaId FK on `media_request` rows was being set to NULL shortly after insert caused by `mediaRepository.save(media)` being called with the requests relation loaded which in turn triggered TypeORM's cascade reconciliation on all loaded request entities, corrupting the FK. This issue must have even gotten worse when the saves were not being awaited in updateParentStatus which could have caused race conditions between concurrent subscriber methods (updateParentStatus, sendToSonarr, sendToRadarr) all firing from afterInsert. fix #2315
…request status updates
refactor: more loggssss fix: pOTENTIAL FIX
…r active requests exist
902a69c to
d73f039
Compare
68011ce
Description
The
mediaIdFK onmedia_requestrows was being set to NULL shortly after insert. This was caused bymediaRepository.save(media)being called with therequestsrelation loaded, which triggered TypeORM's cascade['insert', 'update']reconciliation on all loaded request entities, corrupting the FK. The issue was compounded by these saves not being awaited inupdateParentStatus, creating race conditions between concurrent subscriber methods (updateParentStatus,sendToSonarr,sendToRadarr) all firing fromafterInsert.Additionally, previously, declining a TV request did not reset the associated season statuses back to UNKNOWN, preventing those seasons from being re-requested. The pending request count check also did not exclude the request being declined or scope to the correct
is4kvariant, causing the media status to remain stuck at PENDING.Related to #2316
Yet the database showed
NULLfor themediaIdcolumn on those same records:How Has This Been Tested?
mediaIdnot nullScreenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extract