t8y2/dbx · error · FileExistsError
Versioned agent artifact already exists: {target}
Error message
Versioned agent artifact already exists: {target} What it means
rename_artifact refuses to overwrite files: when the versioned target path (e.g. dbx-agent-<driver>-<version>-<platform>) already exists in the release directory it raises FileExistsError. This protects previously published versioned artifacts from being silently clobbered by a re-run of the versioning script.
Source
Thrown at agents/scripts/version_agent_artifacts.py:22
from pathlib import Path
NATIVE_DRIVERS = ("cassandra", "hive", "argo", "oracle", "xugu", "kingbase", "iotdb", "neo4j", "vastbase", "duckdb", "rabbitmq", "rocketmq", "zookeeper", "tdengine", "etcd", "etcd2", "sqlite-worker")
PLATFORMS = (
"macos-aarch64",
"macos-x64",
"linux-aarch64",
"linux-x64",
"windows-aarch64",
"windows-x64",
)
def rename_artifact(source: Path, target: Path) -> Path | None:
if not source.exists():
return None
if target.exists():
raise FileExistsError(f"Versioned agent artifact already exists: {target}")
source.rename(target)
return target
def version_agent_artifacts(release_dir: Path, versions: dict[str, str]) -> list[Path]:
renamed: list[Path] = []
for driver, version in sorted(versions.items()):
jar = rename_artifact(
release_dir / f"dbx-agent-{driver}.jar",
release_dir / f"dbx-agent-{driver}-{version}.jar",
)
if jar:
renamed.append(jar)
for driver in NATIVE_DRIVERS:
version = versions.get(driver)
if not version:
raise ValueError(f"Missing version for native driver: {driver}")View on GitHub (pinned to c0390bff16)
Solutions
- Delete the existing target artifact (or clean the release_dir) and re-run the versioning script
- Use a new/unique version number so the target filename does not exist
- Wrap the call in try/except FileExistsError and skip or log when the artifact is already versioned
Example fix
// before
rename_artifact(release_dir / "dbx-agent-hive-linux", release_dir / "dbx-agent-hive-1.2.0-linux")
// after
if not (release_dir / "dbx-agent-hive-1.2.0-linux").exists():
rename_artifact(release_dir / "dbx-agent-hive-linux", release_dir / "dbx-agent-hive-1.2.0-linux") Defensive patterns
Strategy: try-catch
Validate before calling
target = release_dir / f"dbx-agent-{driver}-{version}-{platform}"
if target.exists():
target.unlink() # or pick a new version Try / catch
try:
version_agent_artifacts(release_dir, versions)
except FileExistsError as e:
logger.info("already versioned: %s", e); skip Prevention
- Clean the release directory at the start of each build
- Use unique versions per build; never re-publish an existing version
- Make release jobs idempotent by treating FileExistsError as 'already done'
When it happens
Trigger: Calling version_agent_artifacts() (or rename_artifact() directly) on a release_dir that already contains an artifact with the target versioned name — typically because the script was run twice for the same version.
Common situations: Re-running a release job after a partial failure; rebuilding the same release version without cleaning the output directory; a stale artifact left over from a previous build of the identical version.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- Reusable Java agent package is not a file: {output}
- Reusable native agent package is not a file: {output}
- Missing version for native driver: {driver}
- Custom H2 JDBC JAR does not exist: " + path
- Both H2 PageStore and MVStore files exist for " + base + ";
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/e31bc5fbe766ed73.
Report an issue: GitHub.