Fix stale-package cleanup deleting the new bundle#149
Merged
Conversation
The freshly uploaded bundle is still PendingUpload when we read the draft, so its version field is empty. The previous version-based filter therefore matched it and marked it PendingDelete, and the Store API rejected the PUT (InvalidParameterValue: existing package). Discriminate by fileStatus instead: only inherited 'Uploaded' packages are deleted, while the new 'PendingUpload' bundle is preserved. Add a guard that refuses to commit if no package would survive, and surface API error response bodies via a trap. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.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.
Problem
The first run of the cleanup step (from #148) failed at the
PUT:The draft it read looked like this:
The newly uploaded bundle is still
PendingUpload, so Partner Center hasn't extracted its manifest yet and itsversionfield is empty. Theversion != releasefilter matched the empty string and marked the new bundlePendingDeletetoo — so thePUTtried to delete every package (and you can't set aPendingUploadpackage toPendingDelete), which the API rejected.Fix
Discriminate by
fileStatus, notversion:Uploaded→ mark thosePendingDelete.PendingUpload→ always keep it.This drops all reliance on the version field. Also added:
trapthat prints the API's response body on any failing REST call, so future failures show the real error instead of just the status line.What happens next
The failed run left an uncommitted pending draft on the Store; the next release's
msstore publish --noCommitdeletes any existing pending submission before creating a fresh one, so it's cleaned up automatically — no manual action needed. Merge this, then cut a new release to exercise it.Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com