[fixes] Sentry-driven fixes and small perf wins#1073
Merged
Conversation
The lazy="joined" declared on Entity.entity_concept_links does not fire when the query uses .add_columns(Project.name), causing an N+1 query during serialization (one SELECT entity per concept). Force a batched selectin load so all linked entities are fetched in a single extra query regardless of the main query shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
_get_entity_task_query always applied selectinload(Task.assignees) even when callers pass relations=False, in which case Task.serialize drops join attributes and the loaded Person rows are discarded. On large episodes selectinload chunks at 500 IDs, producing many redundant SELECT task ... JOIN person spans flagged as N+1 by Sentry. Apply the option only when relations=True and propagate the flag through every caller of the helper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Person CRUD endpoints relied on the only_one_email_by_person partial unique index to catch duplicate emails, surfacing the violation as an opaque IntegrityError raised mid-flight by an autoflush in BaseMixin.update_no_commit (the Department.get(id) loop forces a flush after email is already set on the instance). The client received the raw "duplicate key value violates unique constraint" message and Sentry logged the exception at error level, turning routine user mistakes into ongoing noise. Validate email uniqueness explicitly in PersonsResource creation and PersonResource update against the same predicate as the partial index (is_bot is not true), excluding self on update. Bot accounts still bypass the check, matching the index definition. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
filter_by resolves attributes against the last joined entity, which broke get_assets when episode_id forced an EntityLink join and another criterion (e.g. project_id) was supplied. Use field_key == value so the filter clauses carry the model's table reference and stay valid through joins.
ffmpeg's color_primaries/trc/colorspace output flags only tag the metadata, they don't convert pixels. On untagged H.264 sources (typical After Effects export), claiming BT.709 makes players reinterpret the pixel data and shifts perceived colors. Drop the tags so ffmpeg leaves the output's color metadata unset and players fall back to their resolution-based heuristics. Fix cgwire#1071
The preview file can be deleted between the existence check and the entity.update() commit, surfacing as a ForeignKeyViolation on fk_main_preview in async pipelines like prepare_and_store_movie. Catch the IntegrityError and convert it to PreviewFileNotFoundException so existing callers reuse their graceful path for that case.
PlaylistShareLink.playlist_id has no ON DELETE clause, so deleting a playlist that still owns share links surfaced as a ForeignKeyViolation at commit time (Sentry: playlist_share_link_playlist_id_fkey). Mirror the existing remove_playlist pattern (notifications, build jobs) and delete share links before the playlist itself.
… playlists Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Problems
prepare_shotcrashed on orphan shots (deleted parent sequence/episode)apply_criterions_to_db_querybrokefilter_byon joined Entity queriesprepare_and_store_movieraised FK violationSolutions
entity_concept_links; skipTask.assigneesselectinload whenrelations=Falseprepare_shotignore_errorsfilter_byinapply_criterions_to_db_querycolor_primaries/trc/colorspaceffmpeg output flagsIntegrityErrortoPreviewFileNotFoundExceptioninupdate_entity_preview