Skip to content

feat: support extra auth param for docs media download#628

Open
wittam-01 wants to merge 1 commit intomainfrom
feat/docs-media-download-extra
Open

feat: support extra auth param for docs media download#628
wittam-01 wants to merge 1 commit intomainfrom
feat/docs-media-download-extra

Conversation

@wittam-01
Copy link
Copy Markdown
Collaborator

@wittam-01 wittam-01 commented Apr 23, 2026

Summary

This PR adds --extra support to docs +media-download so advanced-permission Base attachments can be downloaded through the Drive media API. It also updates the related skill docs to explain the extra payload structure, usage rules, and masked examples.

Changes

  • Add --extra to docs +media-download and pass it through as the media download query parameter for --type media
  • Update dry-run output and shortcut tests to cover extra handling and query encoding
  • Add a dry-run E2E test for docs +media-download --extra
  • Update lark-doc and lark-base skill docs to document --extra, explain each nested field, and replace example IDs/tokens with masked placeholders

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark xxx command works as expected

Additional verification:

  • go test ./shortcuts/doc -run 'TestDocMediaDownload|TestDocMediaPreviewDryRunUsesMediaEndpoint'
  • go test ./tests/cli_e2e/dryrun -run TestDocs_MediaDownloadDryRunIncludesExtraQueryParam
  • make build

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added --extra flag to document media download command for handling multi-dimensional table attachments with advanced permissions.
  • Tests

    • Added test coverage for the new flag in dry-run and execution modes.
  • Documentation

    • Updated documentation with command examples, parameter requirements, and troubleshooting guidance for the new flag.

Change-Id: I789664715815ef5a6ae883e024d4b4db558b0afa
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

Adds a new --extra CLI flag to the DocMediaDownload command to support advanced permission scenarios for multi-dimensional table attachments. The flag conditionally injects an un-URL-encoded JSON string into API request parameters for non-whiteboard drive media downloads during both dry-run and execution flows.

Changes

Cohort / File(s) Summary
Core Implementation
shortcuts/doc/doc_media_download.go
Introduces --extra flag with conditional injection of extra query parameters into API requests for non-whiteboard downloads in both dry-run and execute modes.
Test Coverage
shortcuts/doc/doc_media_test.go
Adds comprehensive test cases validating that the --extra flag is properly propagated during dry-run and execute workflows, including URL encoding verification.
Skill Flow & Documentation
skills/lark-doc/SKILL.md, skills/lark-doc/references/lark-doc-media-download.md
Updates conditional logic in the media-download decision flow and adds detailed documentation covering parameter constraints, JSON construction guidelines, authentication mechanics, and HTTP 400 error troubleshooting for the --extra flag.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

domain/ccm, size/M

Suggested reviewers

  • liujinkun2025
  • fangshuyu-768

Poem

🐰 A flag hops in with JSON flair,
To unlock tables with care,
Extra params dance through the request,
Non-whiteboard downloads pass the test,
With docs and flows so clear, we're blessed! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly and concisely summarizes the main change: adding support for an extra authentication parameter to the docs media download feature.
Description check ✅ Passed The description follows the template structure with Summary, Changes, Test Plan, and Related Issues sections, providing comprehensive details about the implementation and testing approach.
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/docs-media-download-extra

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/M Single-domain feat or fix with limited business impact labels Apr 23, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
shortcuts/doc/doc_media_test.go (1)

652-679: Tests adequately cover the new --extra propagation.

Dry-run test asserts the param is present on the non-whiteboard path; execute test asserts the fully encoded query string hits the stubbed URL. Good coverage for both flows.

Optional: consider adding a negative case asserting --extra is NOT forwarded when --type whiteboard (the other branch of the new conditional at doc_media_download.go:81). This would lock in the scoping guarantee promised by the docs.

Also applies to: 848-883

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/doc/doc_media_test.go` around lines 652 - 679, Add a negative
dry-run test that verifies the --extra flag is not forwarded when the media type
is whiteboard: create a test (e.g.,
TestDocMediaDownloadDryRunDoesNotIncludeExtraForWhiteboard) that builds a cobra
command like the existing TestDocMediaDownloadDryRunIncludesExtraQueryParam,
sets flags "token", "output", "type" to "whiteboard", and "extra" to the same
JSON string, then call decodeDocDryRun on
DocMediaDownload.DryRun(context.Background(), common.TestNewRuntimeContext(cmd,
nil)) and assert that dry.API has the expected call but that dry.API[0].Params
does not contain an "extra" entry (or that it's nil/empty); use the same helpers
(decodeDocDryRun, DocMediaDownload.DryRun, common.TestNewRuntimeContext) and
name the test to reflect the whiteboard negative case so it covers the alternate
branch introduced around doc_media_download.go:81.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@shortcuts/doc/doc_media_test.go`:
- Around line 652-679: Add a negative dry-run test that verifies the --extra
flag is not forwarded when the media type is whiteboard: create a test (e.g.,
TestDocMediaDownloadDryRunDoesNotIncludeExtraForWhiteboard) that builds a cobra
command like the existing TestDocMediaDownloadDryRunIncludesExtraQueryParam,
sets flags "token", "output", "type" to "whiteboard", and "extra" to the same
JSON string, then call decodeDocDryRun on
DocMediaDownload.DryRun(context.Background(), common.TestNewRuntimeContext(cmd,
nil)) and assert that dry.API has the expected call but that dry.API[0].Params
does not contain an "extra" entry (or that it's nil/empty); use the same helpers
(decodeDocDryRun, DocMediaDownload.DryRun, common.TestNewRuntimeContext) and
name the test to reflect the whiteboard negative case so it covers the alternate
branch introduced around doc_media_download.go:81.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94daf594-70f1-44a0-9da8-7ca697833fb6

📥 Commits

Reviewing files that changed from the base of the PR and between 81d22c6 and 2ef2b19.

📒 Files selected for processing (4)
  • shortcuts/doc/doc_media_download.go
  • shortcuts/doc/doc_media_test.go
  • skills/lark-doc/SKILL.md
  • skills/lark-doc/references/lark-doc-media-download.md

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.09%. Comparing base (81d22c6) to head (2ef2b19).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
+ Coverage   60.20%   62.09%   +1.88%     
==========================================
  Files         407      407              
  Lines       43340    35806    -7534     
==========================================
- Hits        26091    22232    -3859     
+ Misses      15221    11545    -3676     
- Partials     2028     2029       +1     

☔ 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
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/docs-media-download-extra -y -g

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/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant