Skip to content

fix(storage): separate COS origin and CDN delivery modes - #699

Merged
AptS-1547 merged 2 commits into
masterfrom
fix/cos-download-delivery-modes
Nov 3, 2026
Merged

AptS-1547 merged 2 commits into
masterfrom
fix/cos-download-delivery-modes

Conversation

@AptS-1547

@AptS-1547 AptS-1547 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

COS 源站模式此前根据是否填写 download_base_url 隐式选择默认 endpoint 或自定义下载域,导致地址字段始终展示。现在明确区分默认 COS 源站、自定义源站下载域(COS Q-Sign)和腾讯 CDN(Type D / SHA-256):默认源站隐藏并忽略休眠地址,另外两种模式显示并要求填写同一个下载地址。

下载策略仍优先:relay_stream 覆盖交付模式并保留休眠配置;仅 presigned 使用所选直链。上传、multipart 和后端 I/O 继续使用存储 Endpoint,CNAME 配置独立。

实现与升级

  • Descriptor 增加可选 negate 条件,通用表单据此控制地址可见性和必填;缺失值与 JSON null 均不匹配否定条件。后端默认规则与前端条件保持相同语义,同步所有调用方及生成 SDK。
  • 模式分流采用穷尽 match;补充配置、签名目标、API 往返、模式切换和 Playwright 回归。
  • 保留已发布配置的行为:m20261103_000001_cos_download_delivery 只对缺少 download_delivery 且下载地址非空的 COS 配置写入 custom_origin,覆盖保存策略、远端目标及延迟清理快照。显式模式不覆盖,运行时不推断模式;支持幂等执行、事务回滚和 down 迁移。
  • 同步中英文教程、开发者契约和 CHANGELOG,包含 alibaba_oss.rs 条件初始化及格式对齐;基于已合入 feat(storage): support Alibaba OSS Type A CDN download delivery #694 的 master。

验证

  • Rust 工作区库测试:2335 通过、2 跳过;存储策略集成:79 通过。
  • 新增迁移 SQLite 测试:3 通过,覆盖跨批次、策略/目标/快照、幂等、回退与错误回滚。
  • 前端全量 Vitest 3554 通过;review 修复后相关 52 项通过;类型/格式检查与生产构建通过。
  • OpenAPI 导出、SDK 生成、storage docs 生成/漂移检查及中英文用户/开发者文档构建通过。
  • Clippy、Rust 格式与 diff 检查通过。
  • Review 修复后的本地 Playwright 专项 1 项通过,覆盖三种模式切换、地址显隐、创建与编辑时保留加密密钥。
  • 初版 CI 的 Playwright、格式/Clippy、OpenAPI、文档和覆盖率均通过;PostgreSQL 集成唯一失败为 SFTP 镜像拉取遭 registry 限流(3972 通过/1 失败),非 COS 断言失败。推送 review 修复后由新 CI 重新验证。
  • 本机 Docker daemon 不可用,未单独运行 PostgreSQL/MySQL 的旧配置迁移 fixture;迁移使用现有跨数据库 SeaQuery 事务/分页模式。

Related: #693, #697

Summary by CodeRabbit

  • 新功能
    • 腾讯 COS 下载支持默认源站、自定义源站和腾讯 CDN 三种交付方式。自定义源站与 CDN 模式需填写 HTTPS 下载地址;默认源站模式会隐藏该地址且不使用它。
    • 中继下载优先于交付方式设置;切换模式时,隐藏的下载地址仍会保留。Blob 下载和预览可通过 CDN 交付,需精确控制响应头或请求附件时仍使用中继。
    • 存储策略配置支持按条件反向匹配字段值。
  • 文档
    • 补充了腾讯 COS 下载模式、地址配置、授权要求及连接测试范围的说明。

@astercommunity-automation astercommunity-automation Bot added Documentation Improvements or additions to documentation Rust Pull requests that update Rust code TypeScript Pull requests that update JavaScript code Scope: Storage Storage policies, connectors, drivers, provider capabilities, and storage backends Scope: Admin UI Administrator-facing frontend workflows and management interfaces CI: Running A pull request has required CI workflows that have not reached a terminal state labels Nov 3, 2026
@astercommunity-automation

astercommunity-automation Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

PR readiness for 138c81e4f7ab

Fact Value
Blocking conditions 1
Waiting conditions 1
Current unresolved threads 0
Current-head approvals 0
Stale latest reviews 0
  • BLOCK: Current head requires a human approval
  • WAIT: PR Gate: waiting

This report is deterministic and updated for the current pull request head.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Tencent COS 现在提供默认源站、自定义源站 Q-Sign 和腾讯 CDN 三种下载模式。连接器字段条件支持否定比较。驱动按模式解析下载地址;迁移为符合条件的既有配置补充显式模式。

Changes: Tencent COS 下载交付

Layer / File(s) Summary
连接器条件否定比较
crates/aster_drive_storage/src/connector_descriptor.rs, frontend-panel/src/components/admin/storage-policy-dialog/connectorFieldRules.ts, src/storage/connectors/alibaba_oss.rs, src/storage/connectors/onedrive.rs
条件新增默认关闭的 negate 字段。字段缺失或为 null 时不匹配;字段存在时按相等或不等比较。前端匹配逻辑和现有连接器条件使用该字段。
COS 模式配置与字段规则
src/storage/connectors/tencent_cos.rs, src/storage/connectors/tencent_cos/localization.rs, frontend-panel/src/components/admin/storage-policy-dialog/*, frontend-panel/e2e/admin.spec.ts, docs/src/content/docs/{admin,en/admin}/storage-backends/tencent-cos.md, developer-docs/zh-CN/design/storage-descriptor-normalization-contract.md, CHANGELOG*.md
新增 custom_origin 模式。自定义源站和 CDN 模式显示并要求下载地址;CDN 密钥和有效期仍仅在 CDN 模式显示。文档和测试说明模式切换、地址字段及 relay_stream 优先级。
COS 下载路由与验证
src/storage/drivers/tencent_cos/*, src/storage/connectors/tests.rs, tests/storage/policies.rs
驱动按交付模式解析下载地址:默认源站委托 S3 驱动,自定义源站生成签名 URL,CDN 使用现有 CDN 路径。上传和分块上传继续使用 COS Endpoint。测试覆盖配置校验、下载 URL 和 relay 设置保留。
既有配置迁移
crates/aster_drive_migration/src/lib.rs, crates/aster_drive_migration/src/m20261103_000001_cos_download_delivery.rs
新增可逆迁移,覆盖存储策略、远端目标和延迟清理快照。迁移只为缺少模式且下载地址非空的 COS 配置补充 custom_origin,并保留显式模式。

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AsterDrive
  participant TencentCosDriver
  participant S3StorageDriver
  participant CustomOrigin
  participant TencentCDN
  AsterDrive->>TencentCosDriver: 请求 presigned 下载
  alt cos_origin
    TencentCosDriver->>S3StorageDriver: 解析 COS 源站下载地址
  else custom_origin
    TencentCosDriver->>CustomOrigin: 生成限时签名 URL
  else tencent_cdn_type_d_sha256
    TencentCosDriver->>TencentCDN: 生成 CDN 下载请求
  end
Loading

Possibly related issues

Suggested labels: Risk: High

Suggested reviewers: will36900

Merge Risk: Minimal · up to 138c8

No unresolved issue identified here blocks merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed 标题 "fix(storage): separate COS origin and CDN delivery modes" 描述了 PR 的主要变更:腾讯 COS 下载交付拆分为默认源站、自定义源站和 CDN 三种模式。变更集中也包含 negate 条件、迁移和文档,但标题聚焦于核心意图,属于相关且具体的标题。
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.
Description check Passed PR 描述覆盖了模板的核心信息:变更内容(三种下载交付模式、negate 条件、中继优先级)、实现与升级说明(可逆迁移、文档同步)以及验证结果。但模板的 Summary 与 Test plan 复选框格式未按模板结构呈现,Notes for reviewers 中的数据库迁移、运行时配置变更字段也只以段落形式描述。作者还称 Rust 工作区测试与 Clippy 等部分结果仍在确认中,但在验证部分又…
Full details: Description check

Explanation

PR 描述覆盖了模板的核心信息:变更内容(三种下载交付模式、negate 条件、中继优先级)、实现与升级说明(可逆迁移、文档同步)以及验证结果。但模板的 Summary 与 Test plan 复选框格式未按模板结构呈现,Notes for reviewers 中的数据库迁移、运行时配置变更字段也只以段落形式描述。作者还称 Rust 工作区测试与 Clippy 等部分结果仍在确认中,但在验证部分又列出了已通过结果,二者存在不一致。

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 16 files. (5 skipped: 5 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/kotlin/security/weak-hash-sha1-kotlin.yml

Biome (2.5.15)
frontend-panel/src/components/admin/storage-policy-dialog/connectorFieldRules.test.ts

Biome could not lint this file: configuration resulted in errors. Check the repository's Biome configuration and plugins.

frontend-panel/src/components/admin/storage-policy-dialog/connectorFieldRules.ts

Biome could not lint this file: configuration resulted in errors. Check the repository's Biome configuration and plugins.

三条下载路,各循所选模式
源站守 Endpoint,签名落在自定义域
CDN 带着密钥,按规则生成请求
Relay 优先,设置仍留存
旧配置迁移,新模式有据可循

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 7fd200cc-7011-4021-a21b-cb15d52d66a8
Commits

Reviewing files that changed from the base of the PR and between ac9cff9 and 138c81e.

Files ignored due to path filters: 1
  • frontend-panel/src/services/api.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 10
  • CHANGELOG.md
  • CHANGELOG.zh.md
  • crates/aster_drive_migration/src/lib.rs
  • crates/aster_drive_migration/src/m20261103_000001_cos_download_delivery.rs
  • crates/aster_drive_storage/src/connector_descriptor.rs
  • developer-docs/zh-CN/design/storage-descriptor-normalization-contract.md
  • docs/src/content/docs/admin/storage-backends/tencent-cos.md
  • docs/src/content/docs/en/admin/storage-backends/tencent-cos.md
  • frontend-panel/src/components/admin/storage-policy-dialog/connectorFieldRules.test.ts
  • frontend-panel/src/components/admin/storage-policy-dialog/connectorFieldRules.ts
Files skipped from review as they are similar to previous changes: 3
  • CHANGELOG.zh.md
  • developer-docs/zh-CN/design/storage-descriptor-normalization-contract.md
  • CHANGELOG.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@coderabbitai coderabbitai Bot added the Risk: High Changes a high-risk data, security, protocol, or deployment boundary label Nov 3, 2026
@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.46547% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...tion/src/m20261103_000001_cos_download_delivery.rs 98.45% 5 Missing ⚠️
src/storage/drivers/tencent_cos/mod.rs 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@astercommunity-automation

astercommunity-automation Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

CI diagnostics for 138c81e4f7ab

Workflow Result First failing job/step
Rust CI WAIT -
Frontend CI PASS -
E2E PASS -
Docs Check PASS -
Multi-Primary E2E PASS -

This comment is updated in place for the latest PR head.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread src/storage/drivers/tencent_cos/mod.rs Resolved
@AptS-1547 AptS-1547 self-assigned this Nov 3, 2026
@AptS-1547
AptS-1547 merged commit ebbe848 into master Nov 3, 2026
19 of 24 checks passed
@astercommunity-automation astercommunity-automation Bot added Merged Pull request has been merged and removed CI: Running A pull request has required CI workflows that have not reached a terminal state labels Nov 3, 2026
@AptS-1547
AptS-1547 deleted the fix/cos-download-delivery-modes branch November 3, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Merged Pull request has been merged Risk: High Changes a high-risk data, security, protocol, or deployment boundary Rust Pull requests that update Rust code Scope: Admin UI Administrator-facing frontend workflows and management interfaces Scope: Storage Storage policies, connectors, drivers, provider capabilities, and storage backends TypeScript Pull requests that update JavaScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant