Repository navigation
fix(cues): classify a cue's media without raising; editor raises named, engine logs (869fej07m) - #16
Merged
Merged
Conversation
…d, engine logs (869fej07m)
Both readers of a cue's media guarded with hasattr(cue.media, 'file_name'),
but file_name is a property that raises KeyError, which hasattr does not
catch. A client that drops a cue's media block (the UI does when the file is
not in its library list) produced an empty Media object and the editor's save
died inside the atomic block with a bare KeyError 'file_name'.
- MediaCue.media_status() -> ('none' | 'invalid' | 'ok', file_name): the
non-raising classifier. 'none' is no media object at all (an empty <Media/>
or JSON Media: null decode to None); 'invalid' is a media block without a
file_name key, with an empty file_name, or without an id key.
- CueList.get_media (editor path: update, new, duplicate, relink): 'invalid'
raises a named ValueError that says which cue, so a save that dropped the
media never gets written; 'none' is logged at WARNING and skipped so legacy
projects stay listable and duplicable (refusing to save that shape is the
editor validator's job).
- CuemsScript.get_own_media (engine path, every node, every load): never
raises; both shapes are logged at ERROR and left out of the media list, the
project still loads and that cue fails at arm, locally, as an empty
<Media/> always did.
Version 0.1.0rc16. Suite 625 passed (test2 venv).
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
What
MediaCue.media_status()→('none' | 'invalid' | 'ok', file_name), a non-raising classifier, and the two readers of a cue's media use it with different behaviours:CueList.get_media(editor path: update, new, duplicate, relink): a media block without a usable file (invalid) raises a namedValueErrorthat says which cue; no media object at all (None, what an empty<Media/>or JSONMedia: nulldecodes to) is logged at WARNING and skipped, so legacy projects stay listable and duplicable.CuemsScript.get_own_media(engine path, every node, every load): never raises — both shapes are logged at ERROR and left out; the project still loads and that cue fails at arm, locally, as an empty<Media/>always did.Why
Both guarded with
hasattr(cue.media, 'file_name'), butfile_nameis a property that raisesKeyError, whichhasattrdoes not catch. A client that drops a cue's media block (the UI does when the file is not in its library list) produced an emptyMediaobject and the editor's save died with a bareKeyError 'file_name'inside the atomic block. Silently skipping instead would have let the save write an empty<Media/>and lose the cue's media; raising in the engine path would have made such a project unloadable on every node (first and second Opus reviews of the plan,cuems-RELATIONS/Plans/2026-10-08-edit-save-media-listupdate-cache-bridge-names.md).Verification
19 new tests (
tests/test_media_guards.py): both functions × {None, {}, missing/emptyfile_name, missingid, good}, nested CueLists, the<Media/>-as-None shape; suite 625 passed on test2's venv. Ruff: no new findings (CI runs pytest only).Version 0.1.0rc16. Companion changes: cuems-editor (validator before any write), cuems-frontend (never drops the block). ClickUp 869fej07m.