{"record":{"id":"d6a0087fe6efe8d9","repo":"affaan-m/ECC","slug":"cadence-json-has-no-measured-shots-to-plan-from","errorCode":null,"errorMessage":"cadence.json has no measured shots to plan from","messagePattern":"cadence\\.json has no measured shots to plan from","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/apply.py","lineNumber":161,"sourceCode":"\n    With ``no_repeat=True``, normalized source paths are used at most once;\n    insufficient sources or source durations fail instead of repeating clips.\n    Strict plans fill the nearest whole-frame target and never exceed source\n    capacity. Media duration metadata must describe the available source.\n\n    Returns an application report validated against\n    ``schema.APPLICATION_REPORT_SCHEMA``. The report structurally cannot\n    claim a provider run: ``provider`` is enum-locked to ``\"none\"`` and\n    ``dry_run`` to ``true``.\n    \"\"\"\n    if not media:\n        raise ValueError(\"apply_local needs at least one media clip\")\n\n    if not sp.cadence_path.exists():\n        raise ValueError(\"pack has no measured cadence (cadence.json is missing)\")\n    cadence = sp.read_json(sp.cadence_path)\n    if not isinstance(cadence, dict) or not (cadence.get(\"shots\") or \"mean_shot\" in cadence):\n        raise ValueError(\"cadence.json has no measured shots to plan from\")\n    seq_fps = _positive(fps if fps is not None else cadence.get(\"fps\", _DEFAULT_FPS), \"fps\")\n    validated_media = []\n    for clip in media:\n        if not isinstance(clip, dict) or not isinstance(clip.get(\"path\"), (str, Path)):\n            raise ValueError(\"media clips require a local source path\")\n        if not str(clip[\"path\"]).strip():\n            raise ValueError(\"media clips require a local source path\")\n        validated_media.append({**clip, \"duration\": _positive(clip.get(\"duration\"), \"media duration\")})\n    target = _positive(duration if duration is not None else sum(\n        c[\"duration\"] for c in validated_media\n    ), \"target duration\")\n    planned = plan_shots(cadence, target)\n    assignments = _strict_assign(planned, validated_media, target, seq_fps) if no_repeat else [\n        (validated_media[i % len(validated_media)], max(1, timeline.seconds_to_frames(d, seq_fps)))\n        for i, d in enumerate(planned)\n    ]\n\n    shots: list[dict[str, Any]] = []","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/apply.py#L143-L179","documentation":"apply_local validates that the loaded cadence.json is a dict containing either a 'shots' list or a 'mean_shot' entry. If the file exists but has neither (wrong shape, empty object, or non-dict like a list), planning shot durations is impossible, so it raises ValueError. This guards against corrupted or hand-edited cadence files.","triggerScenarios":"Calling apply_local(sp, ...) where sp.read_json(sp.cadence_path) returns an empty dict {}, a non-dict (list/str), or a dict lacking both 'shots' and 'mean_shot' keys.","commonSituations":"Manually creating a placeholder cadence.json that is empty or has the wrong schema; a cadence build step that produced no shots (e.g. empty input video set) and wrote an empty JSON object; a schema change between library versions.","solutions":["Regenerate cadence.json with the pack's measurement pipeline so it contains 'shots' (or at least 'mean_shot').","Inspect the JSON: it must be an object with a non-empty 'shots' list or a 'mean_shot' key.","Fix hand-edited cadence.json to match the expected schema.","Rebuild the style pack from source media if the cadence data is unrecoverable."],"exampleFix":"// before\ncadence.json -> {}  // apply_local raises\ncadence.json -> []  // apply_local raises\n\n// after\ncadence.json -> {\"shots\": [1.2, 0.8, 1.5], \"fps\": 24}","handlingStrategy":"validation","validationCode":"cad = json.loads(sp.cadence_path.read_text())\nassert isinstance(cad, dict) and (cad.get(\"shots\") or \"mean_shot\" in cad), \"cadence.json invalid\"","typeGuard":"def is_valid_cadence(cad) -> bool:\n    return isinstance(cad, dict) and bool(cad.get(\"shots\") or \"mean_shot\" in cad)","tryCatchPattern":"try:\n    report = apply_local(sp, media=clips)\nexcept ValueError as e:\n    if \"no measured shots\" in str(e):\n        regenerate_cadence(sp)\n        report = apply_local(sp, media=clips)\n    else:\n        raise","preventionTips":["Never hand-edit cadence.json; regenerate it with the measurement pipeline.","Validate cadence.json against the expected schema after every build.","Treat an empty shots list as a build failure in CI."],"tags":["schema","cadence","invalid-json-shape"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}