feat: support wiki sources in drive export#1802
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds URL-driven token/doc-type inference and wiki node resolution to ChangesDrive export URL and wiki resolution
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant Validator
participant WikiAPI as Wiki get_node API
participant DriveAPI as Drive export_tasks API
CLI->>Validator: normalizeDriveExportSpecInput / validateDriveExportSpec
Validator-->>CLI: normalized spec and input source
alt wiki source
CLI->>WikiAPI: GET get_node(wiki token)
WikiAPI-->>CLI: obj_token, obj_type
CLI->>DriveAPI: POST export_tasks(resolved token/type)
else non-wiki source
CLI->>DriveAPI: POST export_tasks(token/type)
DriveAPI-->>CLI: file token invalid
CLI->>WikiAPI: GET get_node(fallback token)
WikiAPI-->>CLI: obj_token, obj_type
CLI->>DriveAPI: POST export_tasks(resolved token/type)
end
DriveAPI-->>CLI: task result
CLI->>CLI: annotateDriveExportWikiOutput(output, wikiResolution)
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1802 +/- ##
==========================================
- Coverage 74.46% 74.40% -0.06%
==========================================
Files 855 860 +5
Lines 88568 90105 +1537
==========================================
+ Hits 65954 67045 +1091
- Misses 17543 17855 +312
- Partials 5071 5205 +134 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@c7345a68840880b1129861d726a659fda82c3187🧩 Skill updatenpx skills add larksuite/cli#feat/drive-export-wiki-source -y -g |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
shortcuts/drive/drive_export_common.go (1)
493-528: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract the retriable error code into a named constant.
1069914(file-token-invalid) is a magic number; a named constant near the other export constants would document intent and make the retry gate self-explanatory.🤖 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/drive/drive_export_common.go` around lines 493 - 528, The retry gate in shouldRetryDriveExportAsWiki currently compares against the magic error code 1069914 directly; extract that value into a named constant near the other drive export constants and use it in shouldRetryDriveExportAsWiki so the intent is self-explanatory. Keep the existing behavior in createDriveExportTaskWithWikiFallback and the retry check unchanged aside from referencing the new constant.
🤖 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/drive/drive_export.go`:
- Around line 186-188: The dry-run hint logic in drive_export.go is too broad:
it currently sets wiki_token_fallback for every non-URL source, which
incorrectly includes bare wiki sources handled by source.Type and
createDriveExportTaskWithWikiFallback. Update the condition around dry.Set so
the hint is only emitted for the actual fallback path, excluding the direct wiki
branch used when --doc-type wiki is resolved up front.
---
Nitpick comments:
In `@shortcuts/drive/drive_export_common.go`:
- Around line 493-528: The retry gate in shouldRetryDriveExportAsWiki currently
compares against the magic error code 1069914 directly; extract that value into
a named constant near the other drive export constants and use it in
shouldRetryDriveExportAsWiki so the intent is self-explanatory. Keep the
existing behavior in createDriveExportTaskWithWikiFallback and the retry check
unchanged aside from referencing the new constant.
🪄 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: c5fe9272-52fc-4556-b19a-ab49d67efc92
📒 Files selected for processing (7)
shortcuts/drive/drive_export.goshortcuts/drive/drive_export_common.goshortcuts/drive/drive_export_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-export.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_export_dryrun_test.go
faa7a92 to
268ae1b
Compare
268ae1b to
c7345a6
Compare
* fix: unify dry-run output contract
* fix: address dry-run review feedback
* fix(dryrun): tighten preview contract and unify data shape
- transcribe HTTP method verbatim in previews (HEAD/OPTIONS were
reported as GET); reject an empty method in api with a typed error
- unify the dry-run data payload across api/service/shortcut paths:
{api, context?: {app_id, user_open_id}}; drop data.as — the envelope
top-level identity is the single identity source
- mark pretty dry-run stdout with '# dry-run: request not sent' so logs
that drop stderr still show it was a preview
- extract the shared preview builder, collapse PrintDryRunWithFile's
loose params into FileUploadMeta, and fail loudly on nil previews
- revert description-marker identity parsing: stale prose must not
override corrected accessTokens (blocks legal user calls on
images.create); identity gating keys off accessTokens only
- pin the new contracts with tests: verbatim method, three-way context
parity, nil-preview error, empty-context omission, marker line
* docs(agents): add typed-data, faithful-transcription, and contract-test conventions
- typed struct at the boundary over map[string]interface{} threading;
distinct types where values could swap silently (internal/meta.Token)
- transcribe input verbatim in previews/transformations; reject
unhonorable flag combinations with typed errors instead of silently
substituting behavior
- contract tests must fail when the implementation is reverted
* test: migrate dry-run tests grown on main to the envelope format
main gained raw-format dry-run readers while the PR was in flight
(wiki drive export #1802, drive list comments #1845, slash commands,
sheets history, docs fetch, mail draft-send/triage, vc meeting events).
Migrate them to the envelope accessors (clie2e.DryRunGet / data-wrapped
decoders) and drop the now-redundant DryRunData extractions in files
unified on DryRunGet.
---------
Co-authored-by: guokexin.02 <264159873+Tantanz20020918@users.noreply.github.com>
Summary
Support Wiki and URL inputs in
drive +exportso agents can pass document URLs or bare Wiki node tokens without guessing the underlyingdoc_type. This resolves Wiki nodes toobj_token/obj_typebefore export and adds actionable validation hints for unsupported export format combinations.Changes
--urland--doc-type wikisupport todrive +export, including Wiki URL pre-resolution and bare Wiki token fallback afterfile token invalid.Test Plan
go test ./shortcuts/drive -run 'TestValidateDriveExportSpec|TestDriveExport' -count=1\n -go test ./shortcuts/sheets -run 'WorkbookExport|SheetExport' -count=1\n- [x] Manual local verification confirms thelark-cli <domain> <command>flow works as expected\n -go build -o /tmp/lark-cli-export-wiki-test .\n -LARK_CLI_BIN=/tmp/lark-cli-export-wiki-test go test ./tests/cli_e2e/drive -run 'TestDriveExportDryRun' -count=1\n -LARK_CLI_BIN=/tmp/lark-cli-export-wiki-test go test ./tests/cli_e2e/sheets -run 'WorkbookExportDryRun' -count=1\n -git diff --check\n -gofmt -l shortcuts/drive/drive_export.go shortcuts/drive/drive_export_common.go shortcuts/drive/drive_export_test.go tests/cli_e2e/drive/drive_export_dryrun_test.go\n\n## Related Issues\n- NoneSummary by CodeRabbit
New Features
drive +exportcan export directly from--url, automatically inferring the document type and token.Bug Fixes
Documentation
--urland explain Wiki handling and retry guidance.