feat: support isv block references in docs xml#1739
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ISV block reference map support to docs v2 fetch, create, and update flows. It introduces an ISV fetch toggle, validates and rewrites ChangesISV block reference map feature
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
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
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@e37b4ef711b8ab2fad6e06e484ef42bbde18bdd2🧩 Skill updatenpx skills add ZEden0/cli#feat/lark-cli-isv-blocks -y -g |
There was a problem hiding this comment.
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 winError-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 assertcategory/subtypeviaerrs.ProblemOforparamviaerrors.As, which the**/*_test.gocoding guidelines require.
shortcuts/doc/html5_block_resources_test.go#L398-450: For each validation error case inTestDocsCreateV2ISVBlockRejectsInvalidAttributes, assertsubtypeandparam(e.g.,param: "type"for the blank-type case,param: "isv-block"for the path+data-ref case) viaerrs.ProblemOf/errors.As.shortcuts/doc/html5_block_resources_test.go#L493-518: InTestDocsUpdateV2ResultFailedReturnsError, assertsubtype == errs.SubtypeServerErrorviaerrs.ProblemOfon theAPIErrorreturned byensureDocsUpdateResultSucceeded.shortcuts/doc/html5_block_resources_test.go#L520-534: InTestDocsUpdateV2ISVBlockRejectsBlankType, assertsubtypeviaerrs.ProblemOfandparam == "type"viaerrors.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
📒 Files selected for processing (3)
shortcuts/doc/docs_update_v2.goshortcuts/doc/html5_block_resources.goshortcuts/doc/html5_block_resources_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- shortcuts/doc/html5_block_resources.go
83eac77 to
72043e9
Compare
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 underreference_map.isv-block, while html5-block behavior remains unchanged.Changes
docs +fetch.reference_map.isv-blockgroup.doc-fetch-resources/{doc_token}/isv_N.data.Test Plan
go test ./shortcuts/docgo build -o ./lark-cli .go test ./tests/cli_e2e/docs -run 'TestDocs_DryRunDefaultsToV2OpenAPI|TestDocs_CreateTitleDryRunPrependsContent'/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
isv-blockresource support alongside existing document block handling.isv-blockreference-map data is offloaded into doc-scoped.datafiles.isv-blockparsing/fetch handling is stricter (requirestype, enforces valid attribute combinations, and ignoresisv-blockinside Markdown code fences).failed.failedbehavior.