fix: disambiguate package version retrieve errors (@W-23089623@)#889
Open
ravipanguluri wants to merge 3 commits into
Open
fix: disambiguate package version retrieve errors (@W-23089623@)#889ravipanguluri wants to merge 3 commits into
ravipanguluri wants to merge 3 commits into
Conversation
Separate the Package2Version lookup into two helpers: resolvePackage2Version runs a disambiguation query that selects only columns any authenticated user can read, and fetchDeveloperUsePkgZipUrl fetches the permission-gated DeveloperUsePkgZip in an isolated query. This keeps the not-found and wrong-Dev-Hub cases from being masked by the "No such column" error a permissionless user hits when the gated column is selected up front. Drop the download-time error remapping helper: once a row is confirmed present with a populated URL, a download failure is genuinely unexpected and should propagate as-is rather than be relabeled.
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.
What & Why
sf package version retrievereturned a single misleading error —"you must first assign yourself the DownloadPackageVersionZips user permission" —
for three genuinely different failure modes:
DownloadPackageVersionZipspermission.Only case 3 is a permission problem, so cases 1 and 2 sent users down a
fruitless perm-debugging detour. This splits the conflated check so each
case reports an actionable message.
@W-23089623@
Work item: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00002cd3UWYAY/view
How
The retrieve flow in
packageVersionRetrieve.tsnow runs two separatePackage2Versionqueries instead of one conflated lookup:resolvePackage2Version) selects only columns anyauthenticated user can read (
Package2Id,ConvertedFromVersionId), so itnever throws before we can classify the failure. If no row is visible in the
running user's Dev Hub, it probes the global
SubscriberPackageVersionview(queryable by any authenticated user) to tell not-found
(
packageVersionNotFound) apart from exists-but-not-in-this-Dev-Hub(
packageVersionNotInDevHub).fetchDeveloperUsePkgZipUrl) fetches thepermission-controlled
DeveloperUsePkgZipin an isolated query, run onlyafter the row is confirmed present. Because existence is already
established, both a "No such column" error and an empty value reliably mean
the user lacks the permission →
developerUsePkgZipFieldUnavailable(unchanged).
Selecting
DeveloperUsePkgZipup front (as before) makes the query throw"No such column" for a user without the permission, which is exactly what
masked cases 1 and 2 as a permission problem. Keeping it out of the
disambiguation query is what restores the three distinct messages.
Two new message keys added to
messages/package.md:packageVersionNotFound,packageVersionNotInDevHub.Tests
Updated/added unit coverage in
packageVersionMetadataRetrieve.test.ts:not-found, not-in-this-Dev-Hub, and missing-permission (empty value and
"No such column").