feat(push): auto-normalize SemVer versions in actor.json to MAJOR.MINOR#1269
Draft
DaveHanns wants to merge 1 commit into
Draft
feat(push): auto-normalize SemVer versions in actor.json to MAJOR.MINOR#1269DaveHanns wants to merge 1 commit into
DaveHanns wants to merge 1 commit into
Conversation
The `version` field in `actor.json` is frequently copied straight from `package.json` (or written from muscle memory) as three-part SemVer — `0.0.1`, `1.0.0`, `1.0.0-beta`. The platform requires strict MAJOR.MINOR and rejects everything else during the build admission step, after the source files have already been uploaded and a build slot has been spent. The error surface is a cryptic 400 that the user learns nothing from; every retry burns a build. PR apify#1245 added a strict client-side guard that fails fast on any non-MAJOR.MINOR version. That's an improvement, but the failure still forces a manual round-trip to edit `actor.json` and re-run `push` — often on a first-time deploy where the user (or an agent driving the CLI) doesn't yet know what Apify's version format is. This change is complementary: before the strict validator runs, detect SemVer-shaped versions we can unambiguously read (`MAJOR.MINOR.PATCH`, optional pre-release identifiers, optional build metadata) and rewrite them to `MAJOR.MINOR` for the current upload, with a warning that tells the user what happened and points at the field to edit for a permanent fix. Non-SemVer garbage (`latest`, `v1`, etc.) falls through to the strict validator unchanged, so this doesn't paper over inputs the CLI can't safely interpret. Behaviour: actor.json version "0.0.1" -> WARN + normalized to "0.0" for this upload; strict validator sees "0.0" and passes. actor.json version "1.0.0-beta" -> WARN + normalized to "1.0". actor.json version "latest" -> unchanged; strict validator rejects with a pointed message. Surfaced during an evaluation of Apify surfaces for agent-driven Actor development. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
versionfield inactor.jsonis frequently copied straight frompackage.json(or written from muscle memory) as three-part SemVer —0.0.1,1.0.0,1.0.0-beta. The platform requires strictMAJOR.MINORand rejects everything else during the build admission step, after the source files have already been uploaded and a build slot has been spent. The error surface is a cryptic 400 that the user learns nothing from; every retry burns a build.#1245 added a strict client-side guard that fails fast on any non-
MAJOR.MINORversion. That's an improvement, but the failure still forces a manual round-trip to editactor.jsonand re-runpush— often on a first-time deploy where the developer (or an agent driving the CLI) doesn't yet know what Apify's version format is.This change is complementary: before the strict validator runs, detect SemVer-shaped versions we can unambiguously read (
MAJOR.MINOR.PATCH, optional pre-release identifiers, optional build metadata) and rewrite them toMAJOR.MINORfor the current upload, with a warning that tells the developer what happened and points at the field to edit for a permanent fix. Non-SemVer garbage (latest,v1, etc.) falls through to the strict validator unchanged, so this doesn't paper over inputs the CLI can't safely interpret.Behaviour
actor.jsonversion0.0.10.0for this upload; strict validator sees0.0and passes1.0.0-beta1.02.3.4-rc.1+build.72.30.0(already valid)latest,v1(not SemVer)Example warning:
Rationale
Developers scaffolding an Actor from scratch — especially in Node ecosystems, where
npm initwrites three-part SemVer by default — trip on this on their very firstapify push. The docs mentionMAJOR.MINORbut it's buried; without an early-and-friendly CLI translation, the developer learns nothing from a 400 error minutes into the flow. This PR letspusheducate + proceed rather than educate + fail.The strict validator from #1245 is intentionally preserved (behind this normalization step) so we still fail fast on inputs the CLI can't unambiguously interpret.
Test plan
apify pushwithactor.jsonversion: "0.0.1"prints the WARN and completes a successful build against a fresh Actorapify pushwithactor.jsonversion: "1.0.0-beta"normalizes to1.0apify pushwithactor.jsonversion: "0.0"(already valid) prints no warningapify pushwithactor.jsonversion: "latest"still fails fast at the strict validator with the existing pointed message (regression check for #1245)apify push -v 0.0.1(flag override) also gets normalizedapify push --jsonstill returns the JSON envelope with the normalizedversionNumberSurfaced during an evaluation of Apify surfaces for agent-driven Actor development.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com