Skip to content

Conversation

@joshi4
Copy link
Contributor

@joshi4 joshi4 commented Nov 7, 2025

reject images larger than 128GiB

@semanticdiff-com
Copy link

semanticdiff-com bot commented Nov 7, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/lib/nodes/image/upload.ts  0% smaller

Copy link
Contributor Author

joshi4 commented Nov 7, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
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 Overview

Greptile Summary

Added client-side validation to reject VM image files larger than 128 GiB before upload begins.

  • Validates file size immediately after stat call on line 99
  • Provides clear error message showing actual file size in GiB
  • Prevents unnecessary API calls and upload attempts for oversized files
  • Implementation is straightforward with proper placement in the upload flow

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Simple validation check with clear error handling, no logic bugs, and appropriate placement in code flow
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/lib/nodes/image/upload.ts 5/5 Added 128GiB file size validation before upload begins, with clear error message showing actual file size

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI
    participant File System
    participant API Server
    participant Object Storage

    User->>CLI: sf nodes images upload -f <file> -n <name>
    CLI->>CLI: Start preparingSpinner
    CLI->>API Server: POST /v1/vms/images/start_upload
    API Server-->>CLI: {image_id}
    CLI->>CLI: Stop preparingSpinner (success)
    
    CLI->>File System: stat(filePath)
    File System-->>CLI: {size, ...}
    
    alt file size > 128 GiB
        CLI->>CLI: throw Error("File size exceeds 128 GiB")
        CLI->>User: Display error and exit
    else file size <= 128 GiB
        CLI->>CLI: Calculate chunk size and parts
        CLI->>CLI: Initialize progress bar
        
        loop For each upload part
            CLI->>API Server: POST /v1/vms/images/{image_id}/upload
            API Server-->>CLI: {upload_url}
            CLI->>File System: readChunk(start, length)
            File System-->>CLI: chunk data
            CLI->>Object Storage: PUT chunk to upload_url
            Object Storage-->>CLI: 200 OK
            CLI->>CLI: Update progress bar
        end
        
        CLI->>CLI: Stop progress bar
        CLI->>CLI: Start finalizingSpinner
        CLI->>File System: Calculate SHA256 hash
        File System-->>CLI: sha256_hash
        CLI->>API Server: PUT /v1/vms/images/{image_id}/complete_upload
        API Server-->>CLI: {image_id, ...}
        CLI->>CLI: Stop finalizingSpinner (success)
        CLI->>User: Display success and next steps
    end
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@joshi4 joshi4 force-pushed the check-image-size-limit branch from 6edcced to e145d21 Compare November 8, 2025 19:02
@joshi4 joshi4 requested a review from sigmachirality November 8, 2025 19:03
@joshi4 joshi4 force-pushed the check-image-size-limit branch from e145d21 to 2a0df2b Compare November 10, 2025 23:38
@joshi4 joshi4 merged commit 90afd9e into main Nov 11, 2025
2 checks passed
sigmachirality pushed a commit that referenced this pull request Nov 27, 2025
reject images larger than 128GiB
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.

3 participants