Skip to content

feat: support isv block references in docs xml#1739

Open
ZEden0 wants to merge 7 commits into
larksuite:mainfrom
ZEden0:feat/lark-cli-isv-blocks
Open

feat: support isv block references in docs xml#1739
ZEden0 wants to merge 7 commits into
larksuite:mainfrom
ZEden0:feat/lark-cli-isv-blocks

Conversation

@ZEden0

@ZEden0 ZEden0 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add lark-cli docs XML support for generic ISV blocks. Fetch now exposes configured ISV blocks as <isv-block type="..." data-ref="..."> with data stored under reference_map.isv-block, while html5-block behavior remains unchanged.

Changes

  • Request ISV block data from ai_edit during docs +fetch.
  • Serialize ISV reference data under the stable reference_map.isv-block group.
  • Emit inline ISV data for small payloads and path-backed resources for larger payloads.
  • Flatten fetched ISV resource paths to doc-fetch-resources/{doc_token}/isv_N.data.
  • Add CLI dry-run and resource handling tests for ISV reference behavior.

Test Plan

  • go test ./shortcuts/doc
  • go build -o ./lark-cli .
  • go test ./tests/cli_e2e/docs -run 'TestDocs_DryRunDefaultsToV2OpenAPI|TestDocs_CreateTitleDryRunPrependsContent'
  • E2E covered fetch, create, replace, delete, missing reference, unknown type, and Lark-brand write rejection paths.
  • Report gate passed for /Users/bytedance/.ccm-harness/worktrees/lark-cli-isv-blocks/larksuite_cli/.lark-cli-e2e-test/reports/isv-timeline-20260703144947/report.md.

Related Issues

N/A

Summary by CodeRabbit

  • New Features
    • Added isv-block resource support alongside existing document block handling.
    • Docs v2 fetch now includes ISV block data in the default request payload.
  • Bug Fixes
    • Large inline isv-block reference-map data is offloaded into doc-scoped .data files.
    • isv-block parsing/fetch handling is stricter (requires type, enforces valid attribute combinations, and ignores isv-block inside Markdown code fences).
    • Docs v2 update now returns an error when the API result is failed.
  • Tests
    • Updated and expanded fetch/create/update and dry-run assertions for ISV defaults and failed behavior.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds ISV block reference map support to docs v2 fetch, create, and update flows. It introduces an ISV fetch toggle, validates and rewrites isv-block tags, materializes block data through .data files, generalizes shared tag handling, validates failed update responses, and expands test coverage.

Changes

ISV block reference map feature

Layer / File(s) Summary
ISV block write-path handling
shortcuts/doc/html5_block_resources.go
Adds isv-block validation, path loading, reference generation, reference-map merging, and generalized tag parsing/rendering for create and update payloads.
ISV fetch-time processing
shortcuts/doc/docs_fetch_v2.go, shortcuts/doc/html5_block_resources.go
Adds return_isv_block_data and processes fetched ISV references, including validation and offloading oversized data to .data files.
Update response validation
shortcuts/doc/docs_update_v2.go
Checks failed update results and formats details from warning or error fields before emitting successful responses.
Flow validation
shortcuts/doc/docs_fetch_v2_test.go, shortcuts/doc/html5_block_resources_test.go, tests/cli_e2e/docs/docs_update_dryrun_test.go, shortcuts/doc/doc_errors_test.go
Covers fetch, create, update, invalid attributes, markdown fences, block deletion, failure responses, validation classification, and file-content preservation.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DocsCreateOrUpdate
  participant ReferenceMapPipeline
  participant DataFile
  DocsCreateOrUpdate->>ReferenceMapPipeline: build request body
  ReferenceMapPipeline->>ReferenceMapPipeline: validate and rewrite isv-block tags
  ReferenceMapPipeline->>DataFile: read referenced .data payload
  DataFile-->>ReferenceMapPipeline: block data
  ReferenceMapPipeline-->>DocsCreateOrUpdate: merged reference_map.isv-block
Loading
sequenceDiagram
  participant DocsFetch
  participant executeFetchV2
  participant processISVBlockReferenceMapForFetch
  participant DataFile
  DocsFetch->>executeFetchV2: fetch with ISV block data enabled
  executeFetchV2->>processISVBlockReferenceMapForFetch: fetched document payload
  processISVBlockReferenceMapForFetch->>DataFile: write oversized block data
  DataFile-->>processISVBlockReferenceMapForFetch: generated .data path
  processISVBlockReferenceMapForFetch-->>executeFetchV2: updated reference map
Loading

Possibly related PRs

  • larksuite/cli#1547: Modifies the same v2 fetch extra-parameter construction and expectations.
  • larksuite/cli#1690: Provides related docs v2 reference_map plumbing for block resources.

Suggested labels: feature

Suggested reviewers: fangshuyu-768, sunpeiyang996

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding ISV block reference support in docs XML.
Description check ✅ Passed The PR description matches the template with Summary, Changes, Test Plan, and Related Issues sections filled in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@e37b4ef711b8ab2fad6e06e484ef42bbde18bdd2

🧩 Skill update

npx skills add ZEden0/cli#feat/lark-cli-isv-blocks -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shortcuts/doc/html5_block_resources_test.go (1)

1-1: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Error-path tests assert only message substrings, not typed error metadata. All three error-path tests share this root cause: they check strings.Contains(err.Error(), ...) but do not assert category/subtype via errs.ProblemOf or param via errors.As, which the **/*_test.go coding guidelines require.

  • shortcuts/doc/html5_block_resources_test.go#L398-450: For each validation error case in TestDocsCreateV2ISVBlockRejectsInvalidAttributes, assert subtype and param (e.g., param: "type" for the blank-type case, param: "isv-block" for the path+data-ref case) via errs.ProblemOf / errors.As.
  • shortcuts/doc/html5_block_resources_test.go#L493-518: In TestDocsUpdateV2ResultFailedReturnsError, assert subtype == errs.SubtypeServerError via errs.ProblemOf on the APIError returned by ensureDocsUpdateResultSucceeded.
  • shortcuts/doc/html5_block_resources_test.go#L520-534: In TestDocsUpdateV2ISVBlockRejectsBlankType, assert subtype via errs.ProblemOf and param == "type" via errors.As(err, &ve) on the *errs.ValidationError.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shortcuts/doc/html5_block_resources_test.go` at line 1, The error-path tests
in TestDocsCreateV2ISVBlockRejectsInvalidAttributes,
TestDocsUpdateV2ResultFailedReturnsError, and
TestDocsUpdateV2ISVBlockRejectsBlankType only validate message text. Extend each
case to assert typed metadata: use errs.ProblemOf for expected category/subtype,
and errors.As for validation parameters, including "type" and "isv-block";
assert errs.SubtypeServerError for the APIError from
ensureDocsUpdateResultSucceeded.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/doc/html5_block_resources_test.go`:
- Around line 520-534: Update TestDocsUpdateV2ISVBlockRejectsBlankType to
inspect the returned error as an *errs.ValidationError using errors.As, assert
its Param is "type", and use errs.ProblemOf to verify the expected validation
subtype. Replace the message-substring-only check while preserving the existing
failure assertion context.
- Around line 493-518: Update TestDocsUpdateV2ResultFailedReturnsError to
inspect the typed problem metadata from errs.ProblemOf(err) and assert that its
subtype is errs.SubtypeServerError. Retain the existing result and
service-warning checks only as supplemental validation, and ensure the test also
verifies the underlying cause is preserved if the established error contract
exposes it.

---

Outside diff comments:
In `@shortcuts/doc/html5_block_resources_test.go`:
- Line 1: The error-path tests in
TestDocsCreateV2ISVBlockRejectsInvalidAttributes,
TestDocsUpdateV2ResultFailedReturnsError, and
TestDocsUpdateV2ISVBlockRejectsBlankType only validate message text. Extend each
case to assert typed metadata: use errs.ProblemOf for expected category/subtype,
and errors.As for validation parameters, including "type" and "isv-block";
assert errs.SubtypeServerError for the APIError from
ensureDocsUpdateResultSucceeded.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4149fc46-9e8a-4217-b32e-14747102e1ff

📥 Commits

Reviewing files that changed from the base of the PR and between db513b7 and 1b97484.

📒 Files selected for processing (3)
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/html5_block_resources.go
  • shortcuts/doc/html5_block_resources_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/doc/html5_block_resources.go

Comment thread shortcuts/doc/html5_block_resources_test.go
Comment thread shortcuts/doc/html5_block_resources_test.go Outdated
@ZEden0
ZEden0 force-pushed the feat/lark-cli-isv-blocks branch from 83eac77 to 72043e9 Compare July 13, 2026 12:48
@ZEden0
ZEden0 requested a review from liangshuo-1 as a code owner July 14, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant