Skip to content

fix(cli): reject off-tier template cpu/memory pairs before the API - #96

Merged
robertohluna merged 1 commit into
mainfrom
fix/cli-templates-shape-validation-20260829
Aug 29, 2026
Merged

fix(cli): reject off-tier template cpu/memory pairs before the API#96
robertohluna merged 1 commit into
mainfrom
fix/cli-templates-shape-validation-20260829

Conversation

@robertohluna

Copy link
Copy Markdown
Contributor

Follow-up to #94 (already merged), addressing coordinator feedback on the templates create resource flags.

Problem

The backend only accepts published vCPU/memory pairs:

size vCPU memory
xs 1 2048 MiB
small 2 4096 MiB
medium 4 8192 MiB
large 8 16384 MiB
xl 16 32768 MiB

Disk is a free-form floor. After #94, templates create forwarded any --cpu/--memory combination, so an off-tier pair like --cpu 4 --memory 4gb (4 vCPU / 4 GB) was sent and rejected by the platform with a shape-mismatch 500 — after the Dockerfile upload.

Fix

templates create now resolves resources locally (resolveTemplateResources) and refuses off-tier pairs before any API call:

  • A --cpu/--memory pair must match a published shape; a missing member is filled from --size (or small).
  • Off-tier pair → fail fast with an actionable message naming the nearest size, e.g.:
    cpu/memory 4/4096 isn't a supported pair; nearest is medium (4 vCPU / 8192 MiB); pass --size medium
  • A pair that conflicts with an explicit --size is rejected (match large, not --size small).
  • --disk stays free-form; --size <name> alone is always safe; with no cpu/memory pins the fields are omitted so the server defaults.

Verification

  • npm run build (tsc): clean.
  • npm test: 431 pass (67 files), incl. a new off-tier rejection test; the prior test updated to a valid medium pair (4 vCPU / 8 GB).
  • Live (built CLI): off-tier 4/4gb and 3/6gb fail locally with nearest-size hints; 8/16gb --size small reports the conflict; valid 2/4gb and --size large pass validation and proceed to the API. All emit clean JSON.

No version bump.

Follow-up to #94. The backend only accepts PUBLISHED vCPU/memory pairs
(xs 1/2048, small 2/4096, medium 4/8192, large 8/16384, xl 16/32768); disk is
a free-form floor. `templates create` previously forwarded any --cpu/--memory
combination, so an off-tier pair like --cpu 4 --memory 4gb (4 vCPU / 4 GB) was
sent and rejected by the platform with a shape-mismatch 500 after the Dockerfile
upload.

Now `templates create` resolves resources locally: a --cpu/--memory pair must
match a published shape. An off-tier pair fails fast before any API call with an
actionable message naming the nearest size (e.g. "cpu/memory 4/4096 isn't a
supported pair; nearest is medium (4 vCPU / 8192 MiB); pass --size medium").
A pair that conflicts with an explicit --size is also rejected. --disk stays
free-form and --size <name> is always safe. When no cpu/memory pins are given,
resources are still omitted so the server picks its default.

No version bump. tsc clean; 431 tests pass, incl. a new off-tier rejection test.
@robertohluna
robertohluna merged commit 1acd9cf into main Aug 29, 2026
2 checks passed
@robertohluna
robertohluna deleted the fix/cli-templates-shape-validation-20260829 branch August 29, 2026 23:35
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