affaan-m/ECC · error · ValueError

wrong source/audio track kind

Error message

wrong source/audio track kind

What it means

Raised by _binding when the track string of a source binding item does not start with 'audio' when audio=True, or 'video' when audio=False. Each binding must reference a track of the expected kind matching the media type being applied.

Solutions

  1. Make the binding's 'track' kind match the media type: audio media must use 'audio<n>' tracks, video media must use 'video<n>' tracks.
  2. Verify the audio flag/element type feeding _binding is correct for the item being bound.
  3. Fix the template or generated bindings so track prefixes agree with the element's media kind.

Example fix

// before
{'media': audio_media, 'track': 'video1', ...}
// after
{'media': audio_media, 'track': 'audio1', ...}
Defensive patterns

Strategy: validation

Validate before calling

for item in bindings:
    expected = 'audio' if item['media']['kind'] == 'audio' else 'video'
    assert item['track'].startswith(expected), f"track kind mismatch: {item['track']}"

Type guard

def track_kind_matches(item, audio: bool) -> bool:
    t = item.get('track')
    return isinstance(t, str) and t.startswith('audio' if audio else 'video')

Try / catch

try:
    bundle = build_application_bundle(...)
except ValueError as e:
    if 'wrong source/audio track kind' in str(e):
        for item in bindings:
            log.error('kind mismatch', track=item['track'], media=item['media'])
    raise

Prevention

When it happens

Trigger: Calling build_application_bundle with a binding item whose 'track' is 'video1' but is being processed as an audio binding (or vice versa), e.g. an audio media element bound to a video track.

Common situations: Swapped audio/video flags in the caller's data model; templates that place audio elements on video tracks; copy-pasted binding dicts where only 'track' was edited but the media kind wasn't.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/c71b07d49e6423b9. Report an issue: GitHub.

Appendix: source

Thrown at skills/taste-application/scripts/tasteforge/integration.py:244

    required = {"path", "name", "start", "end", "left_offset", "right_offset", "enabled", "properties"}
    if not isinstance(clip, dict) or not required <= clip.keys():
        raise ValueError("native snapshot clip is incomplete")
    _range([clip["start"], clip["end"]], bounds)
    _integer(clip["left_offset"])
    _integer(clip["right_offset"])
    if clip["path"] is not None:
        _text(clip["path"])
    _text(clip["name"])
    if type(clip["enabled"]) is not bool or not isinstance(clip["properties"], dict):
        raise ValueError("native clip state is incomplete")


def _binding(item: Any, tracks: dict, baseline: dict, *, audio: bool = False) -> tuple:
    _object(item, {"media", "track", "clip_index", "media_frames", "fps",
                   "source_range", "timeline_range"})
    track, index = _text(item["track"]), _integer(item["clip_index"])
    if not track.startswith("audio" if audio else "video"):
        raise ValueError("wrong source/audio track kind")
    if track not in tracks or index >= len(tracks[track]):
        raise ValueError("source binding has no native clip")
    clip = tracks[track][index]
    _artifact(item["media"])
    if item["media"]["path"] != clip["path"]:
        raise ValueError("source path does not match native clip")
    if _rate(item["fps"]) != _rate(baseline["fps"]):
        raise ValueError("source fps/retime ambiguity")
    duration = clip["end"] - clip["start"]
    capacity = _integer(item["media_frames"], 1)
    if capacity != clip["left_offset"] + duration + clip["right_offset"]:
        raise ValueError("source capacity does not match native offsets")
    source = _range(item["source_range"], [clip["left_offset"], clip["left_offset"] + duration])
    target = _range(item["timeline_range"], [clip["start"], clip["end"]])
    mapped = [clip["start"] + f - clip["left_offset"] for f in source]
    if mapped != target or (audio and target != [clip["start"], clip["end"]]):
        raise ValueError("source/audio placement must preserve native timing")
    return track, index

View on GitHub (pinned to 8321021c54)