Skip to content

feat: return real tenant URLs for drive +upload and markdown +create#992

Merged
fangshuyu-768 merged 1 commit into
mainfrom
feat/real-upload-url
May 21, 2026
Merged

feat: return real tenant URLs for drive +upload and markdown +create#992
fangshuyu-768 merged 1 commit into
mainfrom
feat/real-upload-url

Conversation

@wittam-01

@wittam-01 wittam-01 commented May 20, 2026

Copy link
Copy Markdown
Collaborator

• ## Summary
Return real tenant-specific URLs for drive +upload and markdown +create. This avoids hardcoded fallback domains and also returns URLs for Wiki-targeted Markdown creation.

Changes

  • Updated drive +upload to return the real tenant URL after upload.
  • Updated markdown +create to return the real tenant URL for both Drive folder and Wiki parent targets.
  • Added dry-run output that reflects the URL lookup step.
  • Left markdown +overwrite unchanged per scope.

Test Plan

  • Unit tests pass: go test ./shortcuts/common ./shortcuts/drive ./shortcuts/markdown
  • Required unit suite passes: make unit-test
  • Static checks pass: go vet ./..., gofmt -l ., go mod tidy, golangci-lint --new-from-rev=origin/main
  • Dry-run E2E passes for Drive and Markdown shortcuts
  • Manual local verification confirms drive +upload and markdown +create return real tenant URLs for Drive and Wiki targets

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • File uploads in Drive and Markdown shortcuts now retrieve real access URLs directly from Drive metadata instead of constructing them, ensuring accurate and reliable file links.
  • Bug Fixes

    • Fixed URL handling for files uploaded to explorers and wikis by using metadata-based lookups instead of fallback URL construction.
  • Authorization Changes

    • Drive operations now require the additional drive:drive.metadata:readonly scope to retrieve metadata during upload operations.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d1873c59-7d77-4c60-b8f7-76d714fdd986

📥 Commits

Reviewing files that changed from the base of the PR and between ac97991 and a6e7060.

📒 Files selected for processing (9)
  • shortcuts/common/drive_meta.go
  • shortcuts/common/drive_meta_test.go
  • shortcuts/drive/drive_io_test.go
  • shortcuts/drive/drive_upload.go
  • shortcuts/markdown/markdown_create.go
  • shortcuts/markdown/markdown_test.go
  • tests/cli_e2e/drive/drive_upload_dryrun_test.go
  • tests/cli_e2e/markdown/markdown_dryrun_test.go
  • tests/cli_e2e/markdown/markdown_workflow_test.go

📝 Walkthrough

Walkthrough

This PR introduces a unified abstraction for fetching Drive file metadata (title and access URL) and integrates it into the Drive upload and Markdown create shortcuts to replace constructed URL logic with real metadata-based access URLs. OAuth scopes are expanded to include metadata read access, and test coverage is updated across unit and e2e layers to validate the new behavior.

Changes

Drive metadata URL unification

Layer / File(s) Summary
Drive metadata abstraction and helpers
shortcuts/common/drive_meta.go, shortcuts/common/drive_meta_test.go
New DriveMeta struct encapsulates Title and URL fields. FetchDriveMeta helper calls /open-apis/drive/v1/metas/batch_query with optional with_url flag, while FetchDriveMetaTitle and FetchDriveMetaURL provide typed convenience wrappers. Unit test validates the URL fetch with with_url: true in request body.
Drive upload metadata integration
shortcuts/drive/drive_upload.go, shortcuts/drive/drive_io_test.go, tests/cli_e2e/drive/drive_upload_dryrun_test.go
DriveUpload now requests drive:drive.metadata:readonly scope. DryRun extends multipart flow to call batch_query with with_url=true. Execute replaces fallback URL construction with FetchDriveMetaURL call. Explorer and wiki upload tests stub metadata responses and validate data.url against returned metadata. Dry-run tests assert additional metadata batch query call with with_url=true in request.
Markdown create metadata integration
shortcuts/markdown/markdown_create.go, shortcuts/markdown/markdown_test.go, tests/cli_e2e/markdown/markdown_dryrun_test.go, tests/cli_e2e/markdown/markdown_workflow_test.go
MarkdownCreate expands OAuth scopes to include metadata read access. DryRun flow adds batch_query call with with_url=true for URL output. Execute switches to FetchDriveMetaURL with stderr warning fallback on failure. Unit tests verify metadata lookup in dry-run assertions for content, wiki-token, and file-based creates. E2e tests assert metadata batch query presence and with_url: true flag across dry-run scenarios. Workflow test updates wiki-parent assertion to expect data.url present instead of absent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • larksuite/cli#947: Introduces the initial FetchDriveMetaTitle helper that this PR refactors into a more general FetchDriveMeta abstraction supporting URL lookups.
  • larksuite/cli#611: Adds --wiki-token support to Drive uploads that this PR's metadata URL logic now leverages for consistent URL resolution across wiki and explorer parents.
  • larksuite/cli#753: Previously added top-level url output to markdown create; this PR replaces the constructed URL approach with metadata-based lookups.

Suggested reviewers

  • fangshuyu-768
  • SunPeiYang996

🐰 Hops with glee,
Metadata now flows so free,
Real URLs at last!
No more fallback cast,
Drive shortcuts shine bright with ease.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: return real tenant URLs for drive +upload and markdown +create' clearly and specifically summarizes the main change: returning real tenant-specific URLs for two CLI shortcuts.
Description check ✅ Passed The pull request description provides a comprehensive summary, detailed changes, thorough test plan with checkmarks, and addresses all required template sections with complete information.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/real-upload-url

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 and usage tips.

@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 May 20, 2026
@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.37931% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.68%. Comparing base (c02a38f) to head (a6e7060).

Files with missing lines Patch % Lines
shortcuts/common/drive_meta.go 92.30% 1 Missing and 1 partial ⚠️
shortcuts/markdown/markdown_create.go 87.50% 1 Missing and 1 partial ⚠️
shortcuts/drive/drive_upload.go 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #992      +/-   ##
==========================================
+ Coverage   67.66%   67.68%   +0.01%     
==========================================
  Files         576      576              
  Lines       54510    54548      +38     
==========================================
+ Hits        36885    36919      +34     
- Misses      14566    14568       +2     
- Partials     3059     3061       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/real-upload-url -y -g

Change-Id: I6b513eef57a3479c8971b3bb6cbf005cad3f8040
@wittam-01
wittam-01 force-pushed the feat/real-upload-url branch from ac97991 to a6e7060 Compare May 20, 2026 09:05
@fangshuyu-768
fangshuyu-768 merged commit e19e090 into main May 21, 2026
21 checks passed
@fangshuyu-768
fangshuyu-768 deleted the feat/real-upload-url branch May 21, 2026 03:07
@liangshuo-1 liangshuo-1 mentioned this pull request May 21, 2026
3 tasks
tuxedomm pushed a commit to zhumiaoxin/cli that referenced this pull request Jun 6, 2026
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.

2 participants