Creating an entry always fails with "This entry has been updated since it was opened" after any unrelated commit (GitHub mode)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- github, github-actions, javascript, typescript
- Lĩnh vực
- backend-api-design, devtools
Hướng nghiên cứu
The bug is in packages/keystatic/src/app/updating.tsx, specifically the useUpsertItem hook and its handling of STALE_DATA errors for creates. Start by reading the issue's suggested fix and the existing logic around treeKey comparisons. Run the reproduction steps locally to confirm the bug, then test the fix by modifying the condition. Verify by checking that creates succeed after unrelated commits and that the dialog still appears if a remote entry with the same slug was created.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version: @keystatic/core 0.6.9 (the same code is on main in packages/keystatic/src/app/updating.tsx)
What happens
In GitHub storage mode, when the branch head has moved since the admin tab was loaded (any commit made elsewhere: a CI bot, a push from a developer, another device), creating a new collection entry shows:
This entry has been updated since it was opened. Create a new branch to save changes.
This happens even though the new entry does not exist on the remote branch and nothing touched its directory. Editing an existing entry in the same situation works: Keystatic retries silently.
Why
On a STALE_DATA error, useUpsertItem fetches the remote tree, computes the tree key of the entry's directories, and retries only if it equals args.currentLocalTreeKey:
if (treeKey === args.currentLocalTreeKey) {
result = await runMutation(refData.data.repository.ref.target.oid);
} else {
setState({ kind: 'needs-new-branch', reason: 'This entry has been updated since it was opened. ...' });
}
For a create, currentLocalTreeKey is undefined, while getTreeKey(...) always returns a string, so the comparison can never succeed and every create after an unrelated commit falls into the "new branch" path. Users who click "Create branch and save" then keep saving to a branch that is never merged.
Reproduction
- GitHub mode, open the admin in tab A.
- Make any commit to the branch that does not touch the collection (from tab B, or
git push). - In tab A, create a new entry and save: the dialog appears.
Suggested fix (one line)
When there is no local tree key, compare against the key of an absent entry (empty tree):
if (treeKey === (args.currentLocalTreeKey ?? getTreeKey(getDirectoriesForTreeKey(object(args.schema), args.basePath, args.slug?.value, args.format), new Map()))) {
This retries when the entry still does not exist remotely, and still shows the dialog if an entry with the same slug was created in the meantime. We apply it as a build-time patch of dist/keystatic-core-ui.js; replaying Keystatic's own tree-key functions against real Git trees gives the expected decision in each case (retry for a new slug after an unrelated commit, dialog for a slug created remotely in the meantime), and in production the create now succeeds after a commit made from another tab.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.5k
- Fork
- 176
- Merge trung bình
- 5 giờ 46 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Thinkmill/keystatic
-
Incorrect Dutch translations: “Save” is translated as “Redden”Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Typo/Grammar on Website HomepageCó thể đã có người làm @Punith1117 đã nhận 147 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Array field: no visible edit button on rows and no close button in the "Edit item" dialogCó thể đã có người làm @bacarndiaye đã nhận 7 ngày trước. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Feature: post-save "publishing" notice / `onCommit` hook so editors know changes aren't live yetĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Thinkmill/keystatic
Issue tương tự
-
category::task code priority::normal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
e0ipso/strikethroo#145 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
cocos/cocos-docs#3333 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
RevenueCat/react-native-purchases#2079 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
RevenueCat/purchases-hybrid-common#2039 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-reported area/react bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày