Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#1,626 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github, github-actions, javascript, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
2.5k
フォーク
176
平均マージ
5時間 46分
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Thinkmill/keystatic のほかの issue

Thinkmill/keystatic の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。