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

Open Beginner friendly
#2,913 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
77/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
cli, documentation

Research direction

Find the docs +update reference and read its block_insert_after result and retry guidance. Update the docs to explain that failed or partial_success can still leave blocks applied, and that clients should re-fetch the target range before retrying. Done when the reference clearly warns about this behavior and the unsafe retry.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Go
Stars
18.2k
Forks
1.4k
Avg merge
1d 3h
Merged PRs (30d)
18

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from larksuite/cli

All issues in larksuite/cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.