CLI: `upsert block --blocks` with two or more blocks fills an empty last child instead of appending, then fails with `add-id-resolution-failed`
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 74/100
調査の方向性
Start with insert_opts in cli/lib/add.ml and trace how it sends insert-blocks; then read get-target-block and insert-blocks in deps/outliner/src/logseq/outliner/core.cljs. Check the documented default for replace-empty-target? against the behavior described in the reproduction. Done means multi-block inserts append after empty-title targets without changing those blocks, and the CLI exits successfully with the created IDs.
索引モデルが issue の本文から書いたものです。
説明
Search first
- I searched and no similar issues were found
What Happened?
upsert block --blocks with two or more blocks writes the first new block into an existing block with an empty title instead of after it. With --pos last-child that is the target block's last child, with --target-page the page's last top-level block, and with --pos sibling the target block itself. The empty block takes the first new block's title and keeps its own uuid. The CLI then looks up the uuids it generated, cannot find the first one, and exits 1 with add-id-resolution-failed: unable to resolve created ids, although every block was written.
Anything on the empty block stays there, so it ends up on the first new block. In variant 5 below, the empty block's heading 2 and its child both end up on the new block one.
The block does not have to be an empty line. Any block with an empty title counts, such as a #Query block or a view block (logseq.property/view-for). A query block at the end of a page, or one targeted with --pos sibling, is lost that way: the first new block becomes the query block, tag and query included (variants 6 and 8).
With a single block, or with --pos first-child, nothing is replaced and the command succeeds.
Reproduce the Bug
G=demo # any DB graph
P=empty-last-child-repro
id() { jq '.data.result[0]'; }
logseq upsert page --graph $G --page $P >/dev/null
PARENT=$(logseq upsert block --graph $G --target-page $P --content parent --output json | id)
EMPTY=$(logseq upsert block --graph $G --target-id $PARENT --pos last-child --content placeholder --output json | id)
logseq upsert block --graph $G --id $EMPTY --update-properties '{:block/title ""}' >/dev/null
logseq upsert block --graph $G --target-id $PARENT --pos last-child --blocks '- one
- two'; echo "exit $?"
logseq show --graph $G --id $PARENT
logseq query --graph $G --query "[:find ?t . :where [$EMPTY :block/title ?t]]"
Output, run on 18-11-2026:
Error (add-id-resolution-failed): unable to resolve created ids
exit 1
575 > empty-last-child-repro
576 parent
577 ├── one
578 └── two
one
Block 577 is $EMPTY, and the last line shows it is now titled one.
Variants, each on a fresh parent or page:
| # | --blocks and options |
Result |
|---|---|---|
| 1 | - one, --pos last-child |
exit 0; one added after the empty block |
| 2 | - one / - two, --pos first-child |
exit 0; empty block untouched |
| 3 | - one with child - one.a, --pos last-child |
exit 1; empty block becomes one |
| 4 | - tree root with child - tree child, then - tree sibling, via --target-page on a page whose last top-level block is empty |
exit 1; empty block becomes tree root |
| 5 | - one / - two, --pos last-child, empty block has heading 2 and a child |
exit 1; one has heading 2 and the child |
| 6 | - one / - two, --target-page on a page whose last top-level block is an untitled #Query block |
exit 1; the query block is now one #Query |
| 7 | same, last top-level block is an untitled block with logseq.property/view-for |
exit 1; the view block is now one |
| 8 | - one / - two, --pos sibling with --target-id an untitled #Query block made in the desktop app |
exit 1; the query block is now one #Query, and its :block/created-at is reset to the time of the insert |
Expected Behavior
--pos last-child, --pos sibling and --target-page add the new blocks after the existing ones and leave existing blocks as they are, empty or not. If filling an empty block is intended, the command should succeed and return the ids of the blocks it actually wrote.
Screenshots
No response
Files
No response
Browser, Desktop or Mobile Platform Information
Linux, logseq --version: revision dad8e9c (nightly 20261118). First seen on 533ac43 on 16-11-2026.
Additional Context
From reading the source at dad8e9c:
insert_optsincli/lib/add.mlsendsinsert-blockswithsibling? false,bottom? trueandkeep-uuid? true, and noreplace-empty-target?.- In
deps/outliner/src/logseq/outliner/core.cljs,get-target-blockturnsbottom?into "sibling of the last child".insert-blocksthen derivesreplace-empty-target?fromnilas(and sibling? <blank title> (> (count blocks) 1)), where the count includes children. So it is true for two or more blocks, while the docstring says it "defaults to befalse". insert-blocks-auxmaps the first block's uuid to the target's, andassign-temp-idgives it the target'sdb/id. The generated uuid never exists,resolve_created_idsfails on it, and because the target block still exists the error staysadd-id-resolution-failed.
Passing :replace-empty-target? false from the CLI would probably avoid it.
This is probably what the master stress run in logseq/logseq#14061 hit (run 44316752188). I searched the logs of the 100 most recent failed CLI sync stress runs (30-09-2026 to 18-11-2026; 21 of the 96 job logs had expired): add-id-resolution-failed appears in 15 of them, every time on create-tree (--target-page with three blocks, the shape of variant 4), and never on create-root or create-child. Those insert a single block and run far more often. They resolve their ids through the same resolve_created_ids, so a race would hit them too, while the two-or-more-blocks rule would not. I could not find which harness operation leaves an untitled block at the end of those pages. The reference views it creates go on the views page, not on the target pages.
Found with the help of an AI coding assistant driving the CLI.
Are you willing to submit a PR? If you know how to fix the bug.
- I'm willing to submit a PR (Thank you!)
- 主要言語
- 言語のデータがありません
- スター
- 29
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
logseq/db-test のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Potential Dataloss: Deleting an entry from the property page's node table has no confirmation dialog対応中かも @tiensonqin が 59 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Disabling Flashcards in Settings does not disable Flashcard shortcuts or tags対応中かも @tiensonqin が 60 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
似ている issue
-
area:core area:install area:sandbox area:state area:tui os:windows
難易度 2/5 半日 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
diivi/aseprite-mcp#43 ·
-
ai-driven-qa bug Critical
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
area: agents
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
manaflow-ai/cmux#50925 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
georgestephanis/diff-leppard#46 ·
メンテナーはふだん 1 日以内に返信