fix: [ENG-2233] complete image upload endpoint is PUT not PATCH#197
Conversation
PUT not PATCHPUT not PATCH
There was a problem hiding this comment.
Greptile Summary
This PR corrects a critical HTTP method mismatch for the complete image upload endpoint from PATCH to PUT in both the OpenAPI schema and client code. The change addresses ticket ENG-2233 and involves two main modifications:
Schema Updates (src/schema.ts):
- Updates the
/v1/vms/images/{image_id}/complete_uploadendpoint definition to use PUT instead of PATCH - Adds a new
vmorch_CompleteUploadRequestschema requiring asha256_hashfield for file integrity verification - Includes a new
archive_batchoperation for POST requests to support batch job management - Adds
image_idfield support for VM nodes
Client Code Fix (src/lib/vm/image/upload.ts):
- Changes the API client call from
client.PATCH()toclient.PUT()for the complete upload endpoint - Removes the
@ts-ignorecomment that was previously needed due to schema mismatch - Maintains the same request structure with path parameters and SHA256 hash in the request body
The fix aligns with REST conventions where PUT is semantically appropriate for completion/finalization operations that represent a complete state change, while PATCH is intended for partial updates. The CLI code was already attempting to use PUT (hence the TypeScript ignore), indicating the schema was out of sync with both the client expectations and likely the actual API implementation. This change ensures type safety and eliminates the schema mismatch that required suppressing TypeScript errors.
Confidence score: 4/5
- This PR addresses a critical HTTP method mismatch but appears safe since the CLI was already attempting to use PUT
- Score reflects the straightforward nature of the fix and alignment with REST conventions, though API contract changes always carry some risk
- Pay close attention to the schema changes in
src/schema.tsto ensure the new request body requirements don't break existing integrations
Context used:
Context - Use HTTP status codes according to the following guidelines: 200 OK for GET, PUT, PATCH success; 201 Created for POST success; 204 No Content for DELETE success; and appropriate client and server error codes as listed. (link)
2 files reviewed, no comments
No description provided.