{"record":{"id":"8638816f10820587","repo":"t8y2/dbx","slug":"reusable-native-agent-package-is-not-a-file-outp","errorCode":null,"errorMessage":"Reusable native agent package is not a file: {output}","messagePattern":"Reusable native agent package is not a file: (.+?)","errorType":"exception","errorClass":"FileExistsError","httpStatus":null,"severity":"error","filePath":"agents/scripts/build_driver_zips.py","lineNumber":105,"sourceCode":"                raise FileExistsError(f\"Reusable Java agent package is not a file: {output}\")\n            update_release_artifact(jar_artifact, output)\n            outputs.append(output)\n\n        for platform, artifact in driver.get(\"native\", {}).items():\n            filename = artifact_filename(artifact[\"url\"])\n            source = release_dir / filename\n            if not source.is_file():\n                raise FileNotFoundError(f\"Native agent artifact missing for {driver_name}/{platform}: {source}\")\n\n            package_driver = copy.deepcopy(driver)\n            package_driver.pop(\"jar\", None)\n            package_driver[\"native\"] = {platform: packaged_artifact(artifact, source)}\n            package_registry = {\"jres\": {}, \"drivers\": {driver_name: package_driver}}\n            output = release_dir / f\"dbx-agent-{driver_name}-{version}-{platform}.tar.zst\"\n            if not output.exists():\n                write_driver_tar_zstd(output, package_registry, source, executable=True)\n            elif not output.is_file():\n                raise FileExistsError(f\"Reusable native agent package is not a file: {output}\")\n            update_release_artifact(artifact, output)\n            outputs.append(output)\n\n    registry_path.write_text(json.dumps(registry, ensure_ascii=False, indent=2) + \"\\n\", encoding=\"utf-8\")\n    return outputs\n\n\ndef remove_raw_driver_artifacts(release_dir: Path) -> list[Path]:\n    removed: list[Path] = []\n    for path in sorted(release_dir.glob(\"dbx-agent-*\")):\n        if path.name.endswith(\".tar.zst\") or not path.is_file():\n            continue\n        path.unlink()\n        removed.append(path)\n    return removed\n\n\ndef main() -> None:","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/scripts/build_driver_zips.py#L87-L123","documentation":"Analogous to the Java case: if the reusable native package dbx-agent-<driver>-<version>-<platform>.tar.zst exists but is not a regular file, build_driver_zips raises FileExistsError rather than overwriting the non-file entry. This prevents clobbering unexpected filesystem objects like directories.","triggerScenarios":"A directory, symlink, or special file occupies the path release_dir/dbx-agent-<driver>-<version>-<platform>.tar.zst so output.exists() is true while output.is_file() is false.","commonSituations":"Extraction tooling created an unpacked directory with the package's name; interrupted script left a partial directory; case-insensitive filesystem collision with a similarly named folder.","solutions":["Delete or rename the offending non-file entry at the reported path so the package can be written.","Use ls -la to identify what the path actually is (directory vs symlink).","Re-run the packaging script to regenerate the tar.zst.","Clean stale package directories in release_dir as part of your release pipeline."],"exampleFix":"# before\nout/dbx-agent-foo-1.0.0-windows-amd64.tar.zst/  # stray directory\n# after\nrm -rf out/dbx-agent-foo-1.0.0-windows-amd64.tar.zst && python build_driver_zips.py","handlingStrategy":"validation","validationCode":"from pathlib import Path\nout = Path(\"out/dbx-agent-foo-1.0.0-windows-amd64.tar.zst\")\nif out.exists() and not out.is_file():\n    raise SystemExit(f\"{out} exists but is not a file; remove it\")","typeGuard":null,"tryCatchPattern":"try:\n    build_driver_zips(release_dir)\nexcept FileExistsError as e:\n    print(f\"{e}; remove the stale entry and rerun\")","preventionTips":["Avoid unpacked directories sharing package names in release_dir","Clean release_dir of non-file entries before packaging","Don't name extraction folders *.tar.zst","Use ls -la to audit release_dir before runs"],"tags":["python","file-exists","packaging","filesystem"],"backgroundTag":"path-is-not-a-file","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}