From 555ab32814ea1abe0b518965686c6adf3bd152db Mon Sep 17 00:00:00 2001 From: Luke Mino-Altherr Date: Thu, 12 Mar 2026 14:57:26 -0700 Subject: [PATCH] Remove unimplemented client-provided ID from upload API The `id` field on UploadAssetSpec was advertised for idempotent creation but never actually honored when creating new references. Remove it rather than implementing the feature. Co-Authored-By: Claude Opus 4.6 --- app/assets/api/routes.py | 24 ------------------------ app/assets/api/schemas_in.py | 2 -- app/assets/services/ingest.py | 1 - 3 files changed, 27 deletions(-) diff --git a/app/assets/api/routes.py b/app/assets/api/routes.py index c1c319893..e011f9a83 100644 --- a/app/assets/api/routes.py +++ b/app/assets/api/routes.py @@ -405,29 +405,6 @@ async def upload_asset(request: web.Request) -> web.Response: ) try: - # Idempotent create: if spec.id is provided, check if reference already exists - if spec.id: - existing = get_asset_detail( - reference_id=spec.id, - owner_id=owner_id, - ) - if existing: - # Validate that uploaded content matches existing asset - if spec.hash and existing.asset and existing.asset.hash != spec.hash: - delete_temp_file_if_exists(parsed.tmp_path) - return _build_error_response( - 409, - "HASH_MISMATCH", - "Uploaded file hash does not match existing asset.", - ) - delete_temp_file_if_exists(parsed.tmp_path) - asset = _build_asset_response(existing) - payload_out = schemas_out.AssetCreated( - **asset.model_dump(), - created_new=False, - ) - return web.json_response(payload_out.model_dump(mode="json", exclude_none=True), status=200) - # Fast path: hash exists, create AssetReference without writing anything if spec.hash and parsed.provided_hash_exists is True: result = create_from_hash( @@ -464,7 +441,6 @@ async def upload_asset(request: web.Request) -> web.Response: expected_hash=spec.hash, mime_type=spec.mime_type, preview_id=spec.preview_id, - asset_id=spec.id, ) except AssetValidationError as e: delete_temp_file_if_exists(parsed.tmp_path) diff --git a/app/assets/api/schemas_in.py b/app/assets/api/schemas_in.py index a4ca72a37..535b31bf0 100644 --- a/app/assets/api/schemas_in.py +++ b/app/assets/api/schemas_in.py @@ -241,7 +241,6 @@ class UploadAssetSpec(BaseModel): - name: display name - user_metadata: arbitrary JSON object (optional) - hash: optional canonical 'blake3:' for validation / fast-path - - id: optional UUID for idempotent creation - mime_type: optional MIME type override - preview_id: optional asset ID for preview @@ -254,7 +253,6 @@ class UploadAssetSpec(BaseModel): name: str | None = Field(default=None, max_length=512, description="Display Name") user_metadata: dict[str, Any] = Field(default_factory=dict) hash: str | None = Field(default=None) - id: str | None = Field(default=None) mime_type: str | None = Field(default=None) preview_id: str | None = Field(default=None) diff --git a/app/assets/services/ingest.py b/app/assets/services/ingest.py index 3edb97470..9502588de 100644 --- a/app/assets/services/ingest.py +++ b/app/assets/services/ingest.py @@ -258,7 +258,6 @@ def upload_from_temp_path( expected_hash: str | None = None, mime_type: str | None = None, preview_id: str | None = None, - asset_id: str | None = None, ) -> UploadResult: try: digest, _ = hashing.compute_blake3_hash(temp_path)