{"record":{"id":"bfe71dd31db86b79","repo":"calesthio/OpenMontage","slug":"invalid-stage-stage-r-for-pipeline-pipeline-ty","errorCode":null,"errorMessage":"Invalid stage: {stage!r} for pipeline {pipeline_type!r}. Valid stages: {sorted(valid_stages)}","messagePattern":"Invalid stage: (.+?) for pipeline (.+?)\\. Valid stages: (.+?)","errorType":"validation","errorClass":"CheckpointValidationError","httpStatus":null,"severity":"error","filePath":"lib/checkpoint.py","lineNumber":177,"sourceCode":"\ndef validate_checkpoint(checkpoint: dict[str, Any]) -> None:\n    \"\"\"Validate checkpoint structure and canonical artifact payloads.\n\n    Uses pipeline_type (if present) to resolve the valid stage list.\n    Falls back to ALL_KNOWN_STAGES when pipeline_type is absent.\n    \"\"\"\n    stage = checkpoint.get(\"stage\")\n    status = checkpoint.get(\"status\")\n    artifacts = checkpoint.get(\"artifacts\")\n    pipeline_type = checkpoint.get(\"pipeline_type\")\n\n    valid_stages = (\n        set(get_pipeline_stages(pipeline_type)) if pipeline_type\n        else ALL_KNOWN_STAGES\n    )\n\n    if not isinstance(stage, str) or stage not in valid_stages:\n        raise CheckpointValidationError(\n            f\"Invalid stage: {stage!r} for pipeline {pipeline_type!r}. \"\n            f\"Valid stages: {sorted(valid_stages)}\"\n        )\n    if not isinstance(status, str):\n        raise CheckpointValidationError(f\"Invalid status: {status!r}\")\n    if not isinstance(artifacts, dict):\n        raise CheckpointValidationError(\"Checkpoint artifacts must be a dictionary\")\n\n    _validate_artifacts_for_stage(stage, status, artifacts)\n\n    try:\n        jsonschema.validate(instance=checkpoint, schema=_load_checkpoint_schema())\n    except jsonschema.ValidationError as exc:\n        raise CheckpointValidationError(f\"Checkpoint failed schema validation: {exc.message}\") from exc\n\n\ndef _checkpoint_path(pipeline_dir: Path, project_id: str, stage: str) -> Path:\n    return pipeline_dir / project_id / f\"checkpoint_{stage}.json\"","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/lib/checkpoint.py#L159-L195","documentation":"_probe_local_audio_duration was given a path that does not exist when ffprobe runs. Usually the file existed during earlier validation but disappeared before probing, or the temp-file write path failed; it is a guard against TOCTOU/missing-file races in audio duration validation.","triggerScenarios":"Another process deletes/moves the audio file between reference validation and probing; a NamedTemporaryFile cleanup (finally: unlink) racing a reuse of temp_path; passing a path that was never created because an earlier step silently failed.","commonSituations":"Concurrent pipelines cleaning a shared tmp directory; retry logic reusing a stale path after cleanup; sandboxed environments where the file lands somewhere else.","solutions":["Confirm the file exists immediately before the call and keep it alive for the duration of the request.","Copy the reference audio into a directory your process owns exclusively.","Retry the generation step end-to-end if a concurrent cleanup is the culprit."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(ref_audio)\nassert p.is_file(), p  # check immediately before the call\n# keep the file on disk until the request finishes","typeGuard":null,"tryCatchPattern":"try:\n    tool.run(inputs)\nexcept ValueError as e:\n    if \"does not exist\" in str(e):\n        restore_or_recreate(ref_audio)  # re-materialize the file, retry once\n    else:\n        raise","preventionTips":["Copy reference audio into a process-owned work directory at the start of each job.","Avoid concurrent tmp-cleaners (systemd-tmpfiles, cron) on directories used for references."],"tags":["python","validation","file-not-found","audio","race-condition","seedance"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}