docs +update block_insert_after: result=failed may still persist non-failing blocks — unsafe to retry, no idempotency

オープン 初心者向け
#2,913 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
77/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
cli, documentation

調査の方向性

docs +updateのリファレンスを見つけ、block_insert_afterの結果と再試行のガイダンスを読みます。failedまたはpartial_successでもブロックが適用されたままになる場合があり、クライアントは再試行の前に対象範囲を再取得する必要があることを説明するよう、ドキュメントを更新します。この動作と安全でない再試行についてリファレンスで明確に警告されていれば完了です。

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

説明

bug domain/doc
Environment
  • @larksuite/cli 1.0.99 (npm), Linux, --as user
  • docs +update --command block_insert_after
Summary

When a single block_insert_after instruction contains multiple blocks and one of them fails server-side (e.g. a <whiteboard token="..."> cross-document clone that cannot be cloned), the API returns result=failed with degrade warnings — but the non-failing blocks of the same instruction are actually persisted. Any retry (a natural response to a failed result, especially in automated batch workflows) duplicates the already-applied blocks.

We verified this repeatedly while doing a large document restructure: a chunked batch-editing script that retried on failed produced 9 copies of the same ~10KB chunk before we noticed. The failed result genuinely looked like "nothing was applied".

Repro
  1. Take any doc with an anchor block. Prepare a whiteboard token from a different document (cross-doc clone is not supported).

  2. One instruction containing three blocks:

    docs +update --command block_insert_after --block-id <anchor> --content \
      '<p>para one</p><whiteboard token="TOKEN_FROM_OTHER_DOC" type="mermaid"></whiteboard><p>para three</p>'
    
  3. Response: result=failed, warnings:

    degrade_code=2105, msg=Whiteboard clone failed. Retry later
    degrade_code=1003, msg=Instruction produced empty content after transform
    
  4. Fetch the region after <anchor>: para one and para three exist despite result=failed (the error message even says "produced empty content", which is not what happened).

  5. Re-run step 2 → a second copy of the paragraphs appears. Repeat → N copies.

Expected

Any of the following would fix the foot-gun:

  1. Atomic per-instruction semantics: apply all blocks or none (rollback on partial failure), or
  2. Truthful reporting: result reflects per-block outcomes and new_blocks lists what was actually applied even when result=failed, or
  3. Idempotency key: accept a client-generated request id so automated retries are safe.
Suggested docs fix (minimum)

At minimum, the +update reference should state that failed/partial_success does not mean "nothing was applied", and that clients must re-fetch the target range to verify before retrying. Right now nothing warns about this, and the degrade message "Retry later" actively encourages the unsafe retry.

Impact

Agent-driven batch editing is a first-class use case for this CLI ("built for humans and AI Agents"). Retrying on failure is the standard recovery pattern for agents; a failed result that silently applied half the instruction turns every retry into silent content duplication at scale.

主要言語
Go
スター
18.2k
フォーク
1.4k
平均マージ
1日 3時間
マージ済み PR(30日)
18

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

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

larksuite/cli のほかの issue

larksuite/cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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