Skip to content

fix: [ENG-2233] complete image upload endpoint is PUT not PATCH#197

Merged
sigmachirality merged 2 commits into
mainfrom
dt/fix-complete-endpoint
Sep 16, 2025
Merged

fix: [ENG-2233] complete image upload endpoint is PUT not PATCH#197
sigmachirality merged 2 commits into
mainfrom
dt/fix-complete-endpoint

Conversation

@sigmachirality
Copy link
Copy Markdown
Member

No description provided.

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Sep 16, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/schema.ts  4% smaller
  src/lib/vm/image/upload.ts  0% smaller

@sigmachirality sigmachirality changed the title fix: complete image upload endpoint is PUT not PATCH fix: [ENG-2233] complete image upload endpoint is PUT not PATCH Sep 16, 2025
@sigmachirality sigmachirality merged commit 392e565 into main Sep 16, 2025
1 check passed
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_upload endpoint definition to use PUT instead of PATCH
  • Adds a new vmorch_CompleteUploadRequest schema requiring a sha256_hash field for file integrity verification
  • Includes a new archive_batch operation for POST requests to support batch job management
  • Adds image_id field support for VM nodes

Client Code Fix (src/lib/vm/image/upload.ts):

  • Changes the API client call from client.PATCH() to client.PUT() for the complete upload endpoint
  • Removes the @ts-ignore comment 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.ts to 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

Edit Code Review Bot Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant