@W-24017820@ fix(package-convert): actionable error when Dev Hub lacks 2GP - #928
agayakwad-salesforce wants to merge 1 commit into
Conversation
|
Thanks for the contribution! It looks like @agayakwad-salesforce is an internal user so signing the CLA is not required. However, we need to confirm this. |
|
This PR lacks any commits of the 'fix' or 'feat' type, and therefore will not trigger a release. To silence all further warnings, react to this warning comment (or any other) with the 👀 emoji. NOTE: If your repo uses squash commits, make sure to add the appropriate conventional commit prefix (e.g., 'fix:', 'feat:', 'chore:', etc) in the squash commit message. |
… 2GP When running sf package convert against a Dev Hub without second-generation managed packaging enabled, the Package2 tooling query in findOrCreatePackage2 threw a raw INVALID_TYPE "sObject type 'Package2' is not supported" error with no actionable guidance. Wrap the Package2 query and the Package2 create path so the "not supported" error is surfaced as a clear, actionable message (convertPackagingNotEnabledOnOrg), consistent with the existing handling in package version retrieve. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ad85325 to
d5ec8f1
Compare
resolved |
@W-24017820@
What does this PR do?
Makes
sf package convert(1GP → 2GP conversion) fail with a clear, actionableerror when run against a Dev Hub org that does not have second-generation managed
packaging enabled.
Previously, the very first server call in the convert flow — the
Package2tooling query in
findOrCreatePackage2— had no error handling and did not routethrough the error-massaging utilities. When the Dev Hub lacked 2GP, the raw
tooling-API error propagated straight to the user:
There was no guidance telling the user the real problem: 2GP packaging isn't
enabled on their Dev Hub.
What's the fix?
In
src/package/packageConvert.ts:Package2tooling query infindOrCreatePackage2in atry/catch. When the error indicatesPackage2is not supported, throw thenew, actionable
convertPackagingNotEnabledOnOrgmessage instead of the rawerror. Any other error is rethrown unchanged.
Package2create path — if the create result reportsthe same "not supported" condition, throw the actionable message rather than
the generic
combineSaveErrorsoutput.isPackage2NotSupportedError, that detects thecondition from either an
Erroror a jsforceSaveErrorobject. It matches ona substring (
sObject type 'Package2' is not supported.) because the fullserver message may append custom-object WSDL boilerplate — consistent with the
existing handling in
packageVersionRetrieve.ts.New user-facing message (
messages/package_version_create.md):This mirrors the existing
packagingNotEnabledOnOrgmessage used bysf package version retrieve, keeping behavior consistent across commands.Before / After
Before
After
The raw
INVALID_TYPE/ "is not supported" text no longer leaks to the user(verified in both human-readable and
--jsonoutput).Scope
This change is intentionally limited to the convert flow. The native
sf package version createpath is out of scope for this PR and is unchanged.Testing
test/package/packageConvert.test.ts:findOrCreatePackage2throws the actionable error when thePackage2queryfails with "not supported".
findOrCreatePackage2throws the actionable error when thePackage2create reports "not supported".
convertPackagesurfaces the actionable error (end-to-end propagation).is not supportedtext does not leak.packageConvert.test.ts— 25 passing.2GP disabled: confirmed the convert command returns
ConvertPackagingNotEnabledOnOrgErrorwith no rawINVALID_TYPEleak in bothdefault and
--jsonoutput.Files changed
src/package/packageConvert.tsmessages/package_version_create.mdtest/package/packageConvert.test.tsIssues
@W-24017820@