Skip to content

fix: infer json extension for downloads#1179

Open
hiSandog wants to merge 1 commit into
larksuite:mainfrom
hiSandog:fix/json-download-extension-20260530
Open

fix: infer json extension for downloads#1179
hiSandog wants to merge 1 commit into
larksuite:mainfrom
hiSandog:fix/json-download-extension-20260530

Conversation

@hiSandog
Copy link
Copy Markdown
Contributor

@hiSandog hiSandog commented May 30, 2026

Summary

When a download response is JSON and the target path has no suffix, extension inference did not add .json because application/json was missing from the MIME map.

Changes

  • Add application/json -> .json to the download MIME extension map.
  • Add unit coverage for JSON Content-Type extension inference.

Test Plan

  • Unit tests pass: env GOCACHE=/private/tmp/cli-gocache GOMODCACHE=/private/tmp/cli-gomodcache go test ./shortcuts/common
  • Manual local verification confirms the lark-cli domain command flow works as expected (not run; helper-only change)

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes
    • Downloads with JSON content now automatically receive the proper .json file extension.
    • Improved automatic file extension detection for various downloaded file types.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b265df6b-5300-4435-a761-9947eccbd316

📥 Commits

Reviewing files that changed from the base of the PR and between d126ea2 and 915c5f0.

📒 Files selected for processing (2)
  • shortcuts/common/download_path.go
  • shortcuts/common/download_path_test.go

📝 Walkthrough

Walkthrough

This PR extends the download file extension inference to recognize JSON MIME types. The mapping now includes application/json alongside existing types like XML, ZIP, images, and video. A test case validates that .json is appended when the Content-Type header is application/json.

Changes

JSON Download Extension Support

Layer / File(s) Summary
JSON MIME type mapping and verification
shortcuts/common/download_path.go, shortcuts/common/download_path_test.go
The downloadMimeToExt mapping adds application/json.json alongside existing MIME types. A test case verifies the extension is appended when downloading content with application/json; charset=utf-8 Content-Type.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

size/M

Suggested reviewers

  • fangshuyu-768

Poem

A rabbit hops through download streams,
JSON files now get their schemes,
With .json tags all neat and tight,
Extensions shine in morning light,
Test cases hop to prove it's right! 🐰

🚥 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 accurately describes the main change: adding JSON extension inference for downloads by mapping application/json MIME type.
Description check ✅ Passed The description includes all required sections (Summary, Changes, Test Plan, Related Issues) with clear explanations of the fix, changes made, and test verification.
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 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 and usage tips.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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