Add mail attachment download URL usage hint#1763
Conversation
Inject the short-lived download URL guidance into successful mail attachment download responses before jq and safety processing. Keep non-target service APIs and business error responses unchanged.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds a ChangesDownload URL usage hint feature
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant HandleResponse
participant serviceResponseTransform
participant injectMailAttachmentDownloadURLHint
Client->>HandleResponse: request mail attachment download_url
HandleResponse->>HandleResponse: decode JSON result
HandleResponse->>serviceResponseTransform: Transform(result)
serviceResponseTransform->>serviceResponseTransform: check schemaPath match
alt schemaPath matches target
serviceResponseTransform->>injectMailAttachmentDownloadURLHint: inject hint into data
injectMailAttachmentDownloadURLHint-->>serviceResponseTransform: updated data
else no match or business error
serviceResponseTransform-->>HandleResponse: unchanged result
end
serviceResponseTransform-->>HandleResponse: transformed result
HandleResponse-->>Client: formatted output
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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@14bf3e88f522b613c259fafa3a8a999b69810b5c🧩 Skill updatenpx skills add bubbmon233/cli#feat/5a2d50b -y -g |
|
🤖 AI Review | CR 汇总 | 有风险(2 个 P2) 本次 GitHub PR 新增运行时 hint 注入和文档说明,相关 Go 包 |
|
|
||
| const mailAttachmentDownloadURLSchemaPath = "mail.user_mailbox.message.attachments.download_url" | ||
|
|
||
| const mailAttachmentDownloadURLUsageHint = "Generate it only when the user is ready to download. Do not send or store it as a long-lived clickable link. download_url is a short-lived pre-signed URL, usually valid for about 2 hours or less and may expire earlier." |
There was a problem hiding this comment.
🤖 AI Review | [P2 正确性] 提示文案遗漏“最多使用两次”的链接约束
cmd/service/service.go 第 33 行的固定 hint 只说明链接大约 2 小时内有效,但技术方案追溯的既有接口说明还包含“下载链接仅可使用两次”。Agent 可能先预取/验证一次链接,再把同一个链接发给用户或在重试链路中复用,导致用户收到的链接已经接近或耗尽使用次数。
修复建议: 把固定 hint、三份 lark-mail reference 和 registry example 统一补充“最多使用两次,不要预取验证后再转发同一 URL;需要下载时重新生成”。
如有疑问或认为判断不准确,欢迎直接回复讨论。
| if resp.StatusCode >= 400 { | ||
| return httpStatusError(resp.StatusCode, resp.RawBody) | ||
| } | ||
| if opts.Transform != nil { |
There was a problem hiding this comment.
🤖 AI Review | [P2 正确性] --output 保存的 JSON 不包含新增 hint
internal/client/response.go 第 115-128 行先把 hint 注入到解析后的 result,但 --output 分支仍调用 saveAndPrint 保存原始 resp.RawBody。因此 mail user_mailbox.message.attachments download_url --output urls.json 落盘的 JSON 没有 data.download_url_usage_hint,stdout 也只是保存元数据;使用 --output 做中间结果持久化的 Agent 仍可能长期保存或转发短时效 URL。
修复建议: 对 JSON 成功响应的 --output 分支保存 transform 后的 JSON,或对该目标 schemaPath 明确拒绝/提示 --output 不包含增强字段;补一条目标 schemaPath + OutputPath 的单测。
如有疑问或认为判断不准确,欢迎直接回复讨论。
This updates mail attachment download handling to include a short-lived URL usage hint in successful responses.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation