fix(cli): reject oversized deployment archives - #370
Conversation
Interaction FlowHere's a sequence diagram showing how the size validation gates remote requests across the affected components: sequenceDiagram
participant User as User (bl deploy / bl push)
participant Deployment as Deployment
participant Archive as Archive (os.Stat)
participant Config as core.Config
participant Remote as Remote API (Apply/ImageBuild)
participant Upload as Upload (presigned PUT)
User->>Deployment: Run deploy/push command
Deployment->>Deployment: Package archive (Tar/Zip)
Deployment->>Archive: ValidateArchiveSize() → os.Stat()
Archive-->>Deployment: fileInfo.Size()
Deployment->>Config: IsVolumeTemplate(config.Type)
Config-->>Deployment: true/false
alt size > 5 GiB (source code)
Deployment-->>User: ❌ "reduce via .blaxelignore"
else size > 5 GiB (volume template)
Deployment-->>User: ❌ "reduce template directory"
else size ≤ 5 GiB
Deployment->>Remote: Send apply / image-build request
Remote-->>Deployment: presigned upload URL
Deployment->>Upload: Upload(url)
Upload->>Archive: os.Stat() (safety re-check)
alt size > 5 GiB (race/edge)
Upload-->>Deployment: errArchiveTooLarge
Deployment->>Deployment: UploadWithRetry skips retry
Deployment-->>User: ❌ size error (no retry)
else OK
Upload-->>Remote: PUT archive bytes
Remote-->>User: ✅ Deploy/push succeeded
end
end
Flow summary: The PR adds a two-layer size gate — an early check right after archive creation (before any network call), and a redundant safety check inside Note Posted by PR Sequence Diagram · Tag @mendral-app with feedback. |
🧪 Testing GuideWhat this PR addresses
Steps to reproduce the original issue
What to verify (expected behavior)
Note Posted by PR Testing Guide · Tag @mendral-app with feedback. |
|
✅ Linked to Linear issue ENG-1907 — status set to In Progress. Note Posted by Linear Issue Enforcer · Tag @mendral-app with feedback. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3b5d7ab. Configure here.
There was a problem hiding this comment.
LGTM
The incremental change correctly wraps errors with MarkExpectedError while preserving the Unwrap chain (classifiedCLIError.Unwrap returns the cause), so errors.Is(err, errArchiveTooLarge) in UploadWithRetry still works. No new issues introduced.
Tag @mendral-app with feedback or questions. View session

Summary
bl deployandbl pushnow reject archives larger than the 5 GiB single-PUT limit before they send remote apply or image-build requests.Volume templates get a metadata-only size check before the CLI creates a temporary TAR. Source-code deployments direct users to
.blaxelignore; volume-template deployments explain that.blaxelignoreis not used and direct users to reduce the template directory.Live dev verification
404, which confirmed that the oversized resource was not created.Verification
make lintgo build ./...make testReview Guide
Why
Blaxel rejects deployment archives larger than 5 GiB. The CLI now detects this local validation failure before it sends unnecessary API or upload requests.
Behavior
bl deployandbl pusharchives before remote requests..blaxelignorefor source archives. Explain that volume templates do not use it.CLIErrorValidation. This prevents expected Sentry noise whileerrors.Is(err, errArchiveTooLarge)remains true.Execution Flow
flowchart LR A[bl deploy or bl push] --> B[Create archive] A --> C[Volume-template metadata scan] C -->|Over 5 GiB| X[Expected validation error] C -->|Within limit| B B --> D[Validate final archive size] D -->|Over 5 GiB| X D -->|Within limit| E[Apply or request upload URL] E --> F[Upload guard] F -->|Over 5 GiB| X F -->|Other upload error| G[Retry with refreshed URL] F -->|Success| H[Complete]Invariants And Failure Paths
size <= 5 GiBis valid;size > 5 GiBis invalid.blaxel.toml, as TAR creation does.UploadWithRetryreturnserrArchiveTooLargeimmediately and does not refresh the URL.core.MarkExpectedErrorpreserves the wrapped sentinel and classifies the failure as expected validation.Reading Order
cli/deploy_test.go- Review boundary, guidance, pre-TAR, sentinel, and no-retry cases.cli/deploy.go- Review the shared limit, error classification, preflight checks, TAR scan, and upload guard.cli/push.go- Confirm that push validates the archive before the image-build request.cli/core/sentry.go- Confirm expected-error unwrapping and Sentry classification behavior.Note
Medium Risk
Changes sit on the main deploy/push and upload paths, but behavior is additive validation with clear errors rather than altered platform contracts.
Overview
bl deployandbl pushnow stop before remote apply orPOST /imageswhen the packaged archive exceeds the 5 GiB single-PUT limit.Shared helpers
ValidateArchiveSize,archiveSizeError, anderrArchiveTooLargecentralize the cap. Oversized source archives tell users to trim via.blaxelignore; volume templates explain that ignore rules do not apply and the template directory must be smaller.Volume templates sum regular-file metadata in
Tar()before creating a temp TAR (skippingblaxel.toml), so huge trees fail fast without a multi‑GB local archive. Interactive deploy runs compression inrunInteractiveDeploymentand validates again after TAR creation.Uploadre-checks size;UploadWithRetrydoes not refresh URLs or retry when the error iserrArchiveTooLarge. Archives at exactly 5 GiB still pass.Reviewed by Cursor Bugbot for commit dc8ae81. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
The latest commit wraps the errors returned by
archiveSizeErrorwithcore.MarkExpectedError(..., core.CLIErrorValidation)so oversized-archive failures are classified as expected validation errors (suppressing Sentry noise) rather than unexpected crashes.Written by Mendral for commit dc8ae81.