{"record":{"id":"0f8fcb1b1d70bb8c","repo":"t8y2/dbx","slug":"reusable-java-agent-package-is-not-a-file-output","errorCode":null,"errorMessage":"Reusable Java agent package is not a file: {output}","messagePattern":"Reusable Java agent package is not a file: (.+?)","errorType":"exception","errorClass":"FileExistsError","httpStatus":null,"severity":"error","filePath":"agents/scripts/build_driver_zips.py","lineNumber":87,"sourceCode":"\n    for driver_name, driver in registry.get(\"drivers\", {}).items():\n        version = driver[\"version\"]\n        jar_artifact = driver.get(\"jar\")\n        if jar_artifact and jar_artifact.get(\"size\", 0) > 0:\n            filename = artifact_filename(jar_artifact[\"url\"])\n            source = release_dir / filename\n            if not source.is_file():\n                raise FileNotFoundError(f\"Java agent artifact missing for {driver_name}: {source}\")\n\n            package_driver = copy.deepcopy(driver)\n            package_driver.pop(\"native\", None)\n            package_driver[\"jar\"] = packaged_artifact(jar_artifact, source)\n            package_registry = {\"jres\": {}, \"drivers\": {driver_name: package_driver}}\n            output = release_dir / f\"dbx-agent-{driver_name}-{version}.tar.zst\"\n            if not output.exists():\n                write_driver_tar_zstd(output, package_registry, source, executable=False)\n            elif not output.is_file():\n                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}\")","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/scripts/build_driver_zips.py#L69-L105","documentation":"When the reusable Java agent package (dbx-agent-<driver>-<version>.tar.zst) already exists but is not a regular file (e.g. a directory or symlink to nowhere), build_driver_zips raises FileExistsError instead of overwriting it. write_driver_tar_zstd is only invoked when the path doesn't exist at all.","triggerScenarios":"A directory named dbx-agent-<driver>-<version>.tar.zst exists in release_dir, or the path is a broken/special filesystem entry, so output.exists() is true but output.is_file() is false.","commonSituations":"An earlier failed script or manual extraction left a directory at that name; rsync/sync tools created placeholder directories; the filename collides with a folder used for unpacked contents.","solutions":["Remove or rename the non-file entry at release_dir/dbx-agent-<driver>-<version>.tar.zst so the script can write the package.","Inspect the path with ls -la to see whether it's a directory, symlink, or other special file.","Re-run the script after cleanup to regenerate a proper package.","Add cleanup of stale/stray package paths to your release tooling."],"exampleFix":"# before\nout/dbx-agent-foo-1.0.0.tar.zst/   # stray directory\n# after\nrm -rf out/dbx-agent-foo-1.0.0.tar.zst && python build_driver_zips.py","handlingStrategy":"validation","validationCode":"from pathlib import Path\nout = Path(\"out/dbx-agent-foo-1.0.0.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}; deleting stale entry\")\n    # remove the reported path and retry once","preventionTips":["Don't extract archives into release_dir under the package's own name","Clean stray directories from release_dir before packaging","Never create directories named *.tar.zst","Check release_dir contents with ls -la before running"],"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"}