Skip to content

fix: no edition warning when scratch org uses snapshot @W-22694430@#1304

Merged
soridalac merged 1 commit into
mainfrom
wr/fixSnapshotEditionWarning
Jun 24, 2026
Merged

fix: no edition warning when scratch org uses snapshot @W-22694430@#1304
soridalac merged 1 commit into
mainfrom
wr/fixSnapshotEditionWarning

Conversation

@WillieRuemmele

@WillieRuemmele WillieRuemmele commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

  • When creating a scratch org from a snapshot (no edition field), a spurious Zod validation warning was emitted: "edition: Invalid input: expected string, received undefined"
  • Root cause: edition was the only non-optional field in ScratchOrgDefSchema, so safeParse always failed for snapshot-based definitions
  • Fix: make edition optional in the schema with an object-level refinement that requires edition unless snapshot is present

Fixes forcedotcom/cli#3562

Work Item

@W-22694430@: Incorrect warning when creating a scratch org from snapshot

Proof of Work

  • Tests: 125 scratch org tests passing, 53 schema tests passing, 57 NUT tests passing
  • Lint: clean (no new warnings)
  • Type check: clean
  • Build: clean (pre-push hooks verified)

Real-World Testing

Linked the built library into plugin-org and tested sf org create scratch end-to-end:

Scenario Before (bug) After (fix)
Snapshot def (no edition) Warning: edition: Invalid input: expected string, received undefined No warning
Valid edition def No warning No warning
Invalid edition value Proper warning with valid options Proper warning with valid options
Empty def (no edition, no snapshot) Generic "expected string, received undefined" Improved: "edition is required unless creating from a snapshot"

Validation

  • Per-task adversarial review: 1 medium finding (empty def regression) — resolved by adding object-level .refine()
  • Integration: all checks pass (unit, NUT, lint, typecheck, build)

Test plan

  • Create a scratch org from a snapshot definition (no edition field) — no warning emitted
  • Create a scratch org with an edition field — validation still works (invalid editions rejected)
  • Create a scratch org with neither snapshot nor edition — improved warning message
  • (Manual) Create a scratch org from a real existing snapshot — confirm successful creation

@WillieRuemmele WillieRuemmele requested a review from a team as a code owner June 24, 2026 15:27
@WillieRuemmele WillieRuemmele force-pushed the wr/fixSnapshotEditionWarning branch from 716a05d to c8203b2 Compare June 24, 2026 15:31
@soridalac

Copy link
Copy Markdown
Contributor

QA notes:
✅ Scratch org from snapshot: no warnings
✅ Edition + snapshot: throws correct error Error (orgSnapshot): Org snapshots don't support one or more options you specified: edition
✅ Lowercase edition: no warnings
✅ Uppercase edition: no warnings

@soridalac

Copy link
Copy Markdown
Contributor

The nut test failings not relate to this PR.

@soridalac soridalac merged commit 2e0501d into main Jun 24, 2026
43 of 68 checks passed
@soridalac soridalac deleted the wr/fixSnapshotEditionWarning branch June 24, 2026 16:42
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.

Incorrect warning when creating a scratch org from snapshot

2 participants