Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Creating an entry always fails with "This entry has been updated since it was opened" after any unrelated commit (GitHub mode)

Đang mở
#1,626 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

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

  1. GitHub mode, open the admin in tab A.
  2. Make any commit to the branch that does not touch the collection (from tab B, or git push).
  3. 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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Thinkmill/keystatic

Tất cả issue của Thinkmill/keystatic

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.