Repository navigation
fix(keystatic): avoid queuing missing files for deletion in parseEntry - #1686
Open
MilindChatrabhuji wants to merge 1 commit into
Open
MilindChatrabhuji wants to merge 1 commit into
MilindChatrabhuji wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 1853453 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch has not been deployed
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
parseEntry(packages/keystatic/src/app/useItemData.ts) so non-existent asset, content, or directory file lookups are not recorded inusedFiles(initialFiles).useUpsertItemanduseDeleteItemfrom requesting deletion of paths that do not exist in the repository tree (which GitHub rejects with[GraphQL] A path was requested for deletion which does not exist as of commit oid ...).Root Cause
In
packages/keystatic/src/app/useItemData.ts,getFileaddedfilepathtousedFilesandTrackedMap.getinvoked#onGet(key)before checking whether the file actually existed infilesWithFakeFile/ the underlyingMap. When an entry referenced a renamed/missing asset file or resolved path not present in the loaded tree, the missing path remained ininitialFiles, causinguseUpsertItem(when not re-added) oruseDeleteItemto include it infileChanges.deletions.Changes
packages/keystatic/src/app/useItemData.ts: guardusedFiles.addingetFilewithfilesWithFakeFile.has(filepath)and guardthis.#onGet(key)inTrackedMap.getwithsuper.has(key).packages/keystatic/src/app/useItemData.test.ts: add unit tests covering missing/mismatched assets, existing referenced assets, unreferenced siblings, and missingcontent/TrackedMaplookups..changeset/fix-missing-initial-files-deletion.md: add patch changeset for@keystatic/core.Addresses the missing-file GraphQL deletion failure (Symptom B) reported in #1627.
Validation
vitest run packages/keystatic/src/app/ packages/keystatic/src/form/field-assertions.test.ts packages/keystatic/src/form/fields/number/isAtStep.test.ts packages/keystatic/src/sha1/sha1.test.ts: 6 files passed, 34 tests passedeslint packages/keystatic/src/app/useItemData.ts packages/keystatic/src/app/useItemData.test.ts: passedprettier --check packages/keystatic/src/app/useItemData.ts packages/keystatic/src/app/useItemData.test.ts .changeset/fix-missing-initial-files-deletion.md: passedpreconstruct validate: passed