{"record":{"id":"816f00b49256276c","repo":"affaan-m/ECC","slug":"capcut-draft-replacement-is-unsafe-choose-a-new-name","errorCode":null,"errorMessage":"CapCut draft replacement is unsafe; choose a new name","messagePattern":"CapCut draft replacement is unsafe; choose a new name","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/media/capcut.py","lineNumber":57,"sourceCode":"                raise ValueError(\"Invalid concat file entry\")\n            files.append((path.parent / fields[1]).resolve())\n    return files\n\n\ndef export_draft(\n    files,\n    drafts,\n    name,\n    width=1920,\n    height=1080,\n    fps=30,\n    overwrite=False,\n    cc=None,\n    probe=duration_of,\n):\n    geometry(width, height, fps)\n    if overwrite:\n        raise ValueError(\"CapCut draft replacement is unsafe; choose a new name\")\n    if not re.fullmatch(r\"[A-Za-z0-9][A-Za-z0-9_. -]{0,99}\", name) or name.endswith(\n        \".\"\n    ):\n        raise ValueError(\"Draft name must be a plain file name\")\n    if not files:\n        raise ValueError(\"At least one video is required\")\n    prepared = []\n    for filename in files:\n        path = Path(filename).resolve(strict=True)\n        duration = probe(path)\n        if not math.isfinite(duration) or duration <= 0:\n            raise ValueError(f\"Invalid media duration: {path.name}\")\n        prepared.append((str(path), duration))\n    if cc is None:\n        import pycapcut as cc\n    folder = cc.DraftFolder(str(drafts))\n    script = folder.create_draft(name, width, height, fps=fps, allow_replace=False)\n    script.add_track(cc.TrackType.video)","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/media/capcut.py#L39-L75","documentation":"export_draft never permits replacing an existing CapCut draft. Passing overwrite=True (or allowing a draft name collision with replacement) aborts the export, because overwriting a CapCut draft directory can destroy user editing work. The error tells you to pick a fresh draft name.","triggerScenarios":"Calling export_draft with overwrite=True, or with a `name` that already exists in the target drafts folder while replacement would be required (create_draft uses allow_replace=False).","commonSituations":"Re-running an export script twice with the same draft name; scripting batch exports that reuse names; assuming overwrite=True would behave like ffmpeg's -y flag.","solutions":["Choose a new, unique draft `name` for the export (add a timestamp or version suffix)","Set overwrite=False and ensure no draft with that name exists in the drafts folder","Delete or rename the existing draft manually in CapCut if it is truly disposable, then re-export with a fresh name","Make your script generate names like f\"draft-{time.strftime('%Y%m%d-%H%M%S')}\""],"exampleFix":"// before\nexport_draft(files, name='my-edit', overwrite=True)\n\n// after\nexport_draft(files, name=f\"my-edit-{int(time.time())}\", overwrite=False)","handlingStrategy":"validation","validationCode":"drafts_dir = Path(drafts)\nassert not overwrite, 'export_draft never permits overwriting drafts'\nassert not (drafts_dir / name).exists(), f'draft {name!r} already exists; pick a new name'","typeGuard":null,"tryCatchPattern":"try:\n    export_draft(files, name=name, overwrite=False)\nexcept ValueError as e:\n    if 'unsafe' in str(e):\n        export_draft(files, name=f'{name}-{int(time.time())}', overwrite=False)","preventionTips":["Never pass overwrite=True; the library refuses it by design","Generate unique draft names with timestamps or UUID suffixes","Check the drafts folder for the name before exporting","Clean up old drafts explicitly rather than relying on replacement"],"tags":["python","capcut","overwrite-safety","draft"],"backgroundTag":"file-already-exists","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"}