fix(etl): persist track bpm/musical_key/audio_upload_id#334
Merged
Conversation
The entity-manager track create/update handlers never wrote bpm, musical_key, is_custom_bpm, is_custom_musical_key, or audio_upload_id, so tracks indexed by go-etl lost these fields entirely. This matches apps' discovery-provider populate_track_record_metadata: - bpm: explicit null clears; a nonzero number sets; 0/absent/non-numeric keeps the existing value. - musical_key: explicit null clears; a valid MusicalKey enum value sets; an invalid value keeps the existing value. Validated against the flats-only enum (e.g. "C# minor" is invalid; "D flat minor" is valid). - is_custom_bpm / is_custom_musical_key / audio_upload_id: set when present, otherwise unchanged. audio_upload_id is also what the repair_audio_analyses backfill job keys on to fetch a track's analysis from the content node. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
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.
Summary
The go-etl entity-manager track create/update handlers never persisted
bpm,musical_key,is_custom_bpm,is_custom_musical_key, oraudio_upload_id. Tracks indexed by go-etl therefore lost these fields entirely (root cause of "tracks uploaded today are missing key/bpm"). This restores parity with apps' discovery-providerpopulate_track_record_metadata.Semantics matched 1:1 to
apps/.../tasks/entity_manager/entities/track.py:null→ clear; present + nonzero number → set; present +0/non-numeric, or absent → keep existing.null→ clear; present + validMusicalKeyenum value → set; present + invalid → keep existing. Validated against the flats-only enum ("C# minor"is invalid;"D flat minor"is valid).audio_upload_idis also the key the companionrepair_audio_analysesbackfill job uses to fetch a track's analysis from the content node.Changes
handler.go: addMetadataFloat64accessor (bpm arrives as a JSON number).validate.go: addvalidMusicalKeysmap +isValidMusicalKey(mirrorsis_valid_musical_key).track_create.go: persist the five fields on insert, with invalid-key → NULL and zero/absent bpm → NULL.track_row.go: load/merge/update/insert the five fields with the keep-on-zero/keep-on-invalid merge semantics.Test plan
go build ./...+go vetclean (pkg/etl module)entity_managersuite green against ephemeral Postgres (sequential-count=1 -p 1, 181s)TestTrackCreate_PersistsBpmAndKey,TestTrackCreate_RejectsInvalidMusicalKey,TestTrackUpdate_PersistsBpmAndKey,TestTrackUpdate_KeepsBpmKeyOnZeroOrInvalid🤖 Generated with Claude Code