Skip to content

feat: check max extension size in publish before uploading - #2087

Merged
netomi merged 3 commits into
mainfrom
check-max-publish-size
Aug 23, 2026
Merged

netomi merged 3 commits into
mainfrom
check-max-publish-size

Conversation

@netomi

@netomi netomi commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

What

Resolves #1953. ovsx publish now checks the packaged extension's size against the registry's configured limit before uploading, instead of only failing after the whole file has been transferred.

The registry's limit is already exposed via /api/version's maxExtensionSize field (added in #1937, and reused by the unpublish command's version check). This is the last consumer-side piece to make the setting actionable for CLI users.

How

  • publish() looks up maxExtensionSize once per invocation and shares it across every target/package being published, avoiding a redundant /api/version call per artifact for multi-target publishes.
  • The check runs in doPublish() right after the file is packaged/resolved, before requesting a PAT or exchanging a trusted-publishing token, so it fails before any unnecessary auth prompt too.
  • Best-effort, like the unpublish version check: a lookup failure, or a registry that doesn't report a limit (older/self-hosted registries), skips the check silently and leaves the server to enforce its own limit as before.
  • The error message mirrors the server's own wording style (FileUtils.byteCountToDisplaySize), via a new small formatBytes() helper.

Testing

  • Added cli/test/unit/publish.spec.ts covering: publish within limit, local rejection over limit (asserting the upload is never attempted), and two fail-open cases (no limit reported, /api/version not exposed).
  • vitest, eslint, and tsc --noEmit all pass.

🤖 Generated with Claude Code

netomi and others added 2 commits August 23, 2026 17:41
Resolves #1953. `/api/version` already exposes maxExtensionSize
(added for the unpublish version check); publish now checks the
packaged extension's size against it before uploading, instead of
failing only after the whole file has been transferred.

The limit is looked up once per `publish()` call and shared across
every target/package being published, to avoid a redundant
/api/version request per artifact. The check is best-effort: a
lookup failure or a registry that doesn't report a limit skips it
silently, leaving the server to enforce its own limit as before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Introduce a proper [next] (unreleased) section instead of stacking new
entries onto the already-released v1.1.1 heading.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a client-side extension size check before ovsx publish authentication and upload.

Changes:

  • Fetches and shares the registry size limit across publish targets.
  • Rejects oversized packages locally.
  • Adds formatting, tests, documentation, and changelog updates.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Review
cli/test/unit/publish.spec.ts Adds size-limit and fail-open tests.
cli/src/util.ts Adds byte-size formatting helper. Nit (4 votes): Formatting does not exactly match the server implementation.
cli/src/publish.ts Enforces the registry size limit before upload. Moderate (4 votes): Preserve a reported limit of 0 instead of treating it as unset.
cli/README.md Documents pre-upload validation.
cli/CHANGELOG.md Records the new behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli/src/publish.ts Resolved
Comment thread cli/src/util.ts Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Thomas Neidhart <thomas.neidhart@gmail.com>
@netomi
netomi merged commit 42b6cd6 into main Aug 23, 2026
5 checks passed
@netomi
netomi deleted the check-max-publish-size branch August 23, 2026 15:53
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.

ovsx CLI tool needs to handle max-content-size before hitting the backend

2 participants