Skip to content

feat(doubao): 接入 Seedance 2.0 素材资产管理 9 个接口#5656

Open
feitianbubu wants to merge 3 commits into
QuantumNous:mainfrom
feitianbubu:feat/doubao-asset
Open

feat(doubao): 接入 Seedance 2.0 素材资产管理 9 个接口#5656
feitianbubu wants to merge 3 commits into
QuantumNous:mainfrom
feitianbubu:feat/doubao-asset

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

接入火山引擎 Seedance 2.0 官方格式的 9 个素材(Asset)管理接口,以代理转发方式统一收口到网关:请求侧用平台 Token 鉴权,网关内部用火山 AK/SK 对上游签名。
官方文档: https://www.volcengine.com/docs/82379/2333589?lang=zh

接口 Method 网关路由
创建素材资产 POST /doubao/open/CreateAsset
创建素材组 POST /doubao/open/CreateAssetGroup
删除素材资产 POST /doubao/open/DeleteAsset
查询素材资产信息 POST /doubao/open/GetAsset
查询素材组信息 POST /doubao/open/GetAssetGroup
查询素材组列表 POST /doubao/open/ListAssetGroups
查询素材资产列表 POST /doubao/open/ListAssets
更新素材资产 POST /doubao/open/UpdateAsset
更新素材组 POST /doubao/open/UpdateAssetGroup

📝 变更描述 / Description

为豆包(火山引擎)新增一套素材资产管理的代理接口,客户端无需自行持有火山 AK/SK,即可通过网关完成素材与素材组的增删改查。实现分三层:

  • 配置层:新增 setting/system_setting/volc_asset.go,定义 VolcAssetSettings(AK/SK、region、project、默认 group 等);通过 model/option.goVolcAssetConfig 接入 options 配置体系,支持热更新。Region 缺省 cn-beijing,GroupType 缺省 AIGC
  • relay 实现层:新增 relay/channel/task/doubao/asset.go,实现对火山 Asset API(service=ark,version=2024-01-01)的请求构造与 AK/SK 签名,覆盖 list/get/create/update/delete asset 与 create/list/get/update asset group。
  • 暴露层:controller/asset.go 提供 9 个 handler,router/video-router.go 注册 /doubao/open/* 路由组,统一走 TokenAuth 鉴权。

生效原理:网关接收客户端的平台 Token 请求 → 取出已配置的火山 AK/SK 对上游做签名 → 透传转发到火山 Asset API 并回传结果,从而屏蔽上游鉴权细节、统一入口与权限控制。

配置说明: 启用前需在 options 表写入一条 key = VolcAssetConfig 的配置(代码已在 InitOptionMap 自动注册并支持热更新,无需改表结构),value 为如下 JSON:

{
  "access_key": "AKLT****your-volc-ak****",
  "secret_key": "****your-volc-sk****",
  "region": "cn-beijing",
  "project_name": "default",
  "group_id": "",
  "group_type": "AIGC"
}

其中 access_key/secret_key 必填,其余可选(region 缺省 cn-beijing,group_type 缺省 AIGC)。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (无)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 不适用(本 PR 为新功能)。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 仅含素材接口相关改动,不含无关代码。
  • 本地验证: 已在本地 go build ./... 通过,并验证路由与接口可用。
  • 安全合规: 代码中无敏感凭据,AK/SK 由部署方在 options 配置,符合项目规范。

📸 运行证明 / Proof of Work

(在此粘贴 9 个接口的调用截图 / 关键日志 / 测试报告)

Summary by CodeRabbit

  • New Features
    • Added asset management API endpoints for listing, retrieving, creating, updating, and deleting assets.
    • Added asset group management API endpoints for listing, retrieving, creating, and updating asset groups.
    • Added configuration support for asset API credentials and settings.

Add VolcAssetSettings (AK/SK, region, project, group) and wire
VolcAssetConfig into the option map for read/update.
Add signed (volc AK/SK) request handlers for the Doubao Asset API:
list/get/create/update/delete assets and create/list/get/update
asset groups.
Register POST /doubao/open/* routes (token-authenticated) and the
controller handlers proxying to the Doubao Asset client.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds a Volcengine Doubao Asset API proxy. A new VolcAssetSettings config struct stores AK/SK credentials and project/group defaults, wired into the option map. A new relay/channel/task/doubao/asset.go implements Volcengine HMAC-SHA256 request signing, a shared upstream proxy helper, and nine CRUD handlers for assets and asset groups. Thin controller relay functions and new router routes expose these handlers.

Changes

Doubao Asset API Proxy

Layer / File(s) Summary
VolcAssetSettings config struct and option map persistence
setting/system_setting/volc_asset.go, model/option.go
Defines VolcAssetSettings with AK/SK, region, project name, group id/type fields, defaulting helpers, and GetBaseURL(). Wires the config into InitOptionMap and updateOptionMap via JSON marshal/unmarshal helpers.
DTOs, Volcengine HMAC-SHA256 signing, and shared doAssetAPICall
relay/channel/task/doubao/asset.go (lines 1–273)
Defines all asset and asset-group request/response DTOs. Implements Volcengine HMAC-SHA256 signing with canonical request construction and scoped key derivation. doAssetAPICall builds the upstream URL, signs and posts the request, caps response at 10 MB, and demultiplexes the response envelope.
Asset CRUD handlers
relay/channel/task/doubao/asset.go (lines 274–412)
Implements HandleListAssets, HandleGetAsset, HandleCreateAsset, HandleUpdateAsset, and HandleDeleteAsset, each validating required fields, applying config defaults, and delegating to doAssetAPICall.
Asset group handlers
relay/channel/task/doubao/asset.go (lines 413–554)
Implements HandleCreateAssetGroup, HandleListAssetGroups, HandleGetAssetGroup, and HandleUpdateAssetGroup with matching validation, filter sanitization, default application, and delegation to doAssetAPICall.
Controller relay functions and route registration
controller/asset.go, router/video-router.go
Thin controller functions forward *gin.Context to each doubao.Handle* handler. Routes registered under /doubao with TokenAuth() middleware via SetVideoRouter.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant DoubaoRouter
  participant Controller
  participant Handler as doubao.Handle*
  participant signRequest
  participant VolcengineArk as Volcengine Ark API

  Client->>DoubaoRouter: POST /doubao/assets/list (TokenAuth)
  DoubaoRouter->>Controller: RelayListAssets(c)
  Controller->>Handler: HandleListAssets(c)
  Handler->>Handler: unmarshal body, apply VolcAssetConfig defaults
  Handler->>signRequest: build + sign POST request (HMAC-SHA256)
  signRequest-->>Handler: Authorization header set
  Handler->>VolcengineArk: POST ?Action=ListAssets&Version=2024-01-01
  VolcengineArk-->>Handler: JSON envelope (Result or Error)
  Handler-->>Client: JSON result or structured error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐇 A rabbit hops through API lanes,
Signing requests with HMAC chains,
Assets and groups all neatly arranged,
Volcengine keys carefully exchanged,
New routes emerge under /doubao's sky—
The proxy is live, credentials fly! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.14% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title in Chinese describes integrating Seedance 2.0 asset management 9 interfaces, which directly matches the PR objective of adding 9 asset management endpoints from Volcano Engine's Seedance 2.0 API to the Doubao gateway.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
relay/channel/task/doubao/asset.go (4)

444-494: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Validate pagination parameters.

HandleListAssetGroups does not validate that PageNumber and PageSize are provided or within acceptable ranges, similar to the issue in HandleListAssets.

✅ Suggested validation
 func HandleListAssetGroups(c *gin.Context) {
 	var req ListAssetGroupsRequest
 	if err := common.UnmarshalBodyReusable(c, &req); err != nil {
 		c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("invalid request body: %v", err)})
 		return
 	}
+	if req.PageNumber <= 0 || req.PageSize <= 0 {
+		c.JSON(http.StatusBadRequest, gin.H{"error": "PageNumber and PageSize must be greater than 0"})
+		return
+	}
 
 	if req.Filter == nil {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/task/doubao/asset.go` around lines 444 - 494, Add validation
for pagination parameters in the HandleListAssetGroups function. After
unmarshaling the request body, validate that PageNumber and PageSize are
provided and within acceptable ranges before proceeding with the API call. If
either parameter is missing or out of range, return a bad request response with
an appropriate error message. This validation should be similar to what is
implemented in HandleListAssets and should occur before the applyDefaults call.

417-438: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Validate required field.

HandleCreateAssetGroup does not validate the required Name field. Validating early provides clearer error messages to the client.

✅ Suggested validation
 func HandleCreateAssetGroup(c *gin.Context) {
 	var req CreateAssetGroupRequest
 	if err := common.UnmarshalBodyReusable(c, &req); err != nil {
 		c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("invalid request body: %v", err)})
 		return
 	}
+	if req.Name == "" {
+		c.JSON(http.StatusBadRequest, gin.H{"error": "Name is required"})
+		return
+	}
 
 	applyDefaults(&req.ProjectName, nil, &req.GroupType)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/task/doubao/asset.go` around lines 417 - 438, The
HandleCreateAssetGroup function does not validate that the required Name field
is present in the CreateAssetGroupRequest struct. Add a validation check
immediately after calling common.UnmarshalBodyReusable to ensure that req.Name
is not empty, and if it is empty, return a clear error response to the client
with an appropriate HTTP status code (such as BadRequest) before proceeding with
the applyDefaults call and further processing.

330-352: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Validate required fields.

HandleCreateAsset does not validate required fields such as URL and AssetType. If the client omits these, the upstream API will reject the request, but validating early provides clearer error messages.

✅ Suggested validation
 func HandleCreateAsset(c *gin.Context) {
 	var req CreateAssetRequest
 	if err := common.UnmarshalBodyReusable(c, &req); err != nil {
 		c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("invalid request body: %v", err)})
 		return
 	}
+	if req.URL == "" {
+		c.JSON(http.StatusBadRequest, gin.H{"error": "URL is required"})
+		return
+	}
+	if req.AssetType == "" {
+		c.JSON(http.StatusBadRequest, gin.H{"error": "AssetType is required"})
+		return
+	}
 
 	applyDefaults(&req.ProjectName, &req.GroupId, nil)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/task/doubao/asset.go` around lines 330 - 352, The
HandleCreateAsset function does not validate required fields before passing the
request to the upstream API. Add validation logic after unmarshaling the request
body to check that the URL and AssetType fields in CreateAssetRequest are not
empty strings. If either field is missing, return a http.StatusBadRequest
response with a clear error message indicating which required field is missing,
similar to the existing error handling pattern in the function. This validation
should occur before calling applyDefaults to ensure invalid requests fail fast
with user-friendly error messages.

276-297: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Validate pagination parameters.

HandleListAssets does not validate that PageNumber and PageSize are provided or within acceptable ranges. If the client omits these fields, they default to 0, which may not be valid for the upstream Volcengine API and could result in confusing error messages.

✅ Suggested validation
 func HandleListAssets(c *gin.Context) {
 	var listReq ListAssetsRequest
 	if err := common.UnmarshalBodyReusable(c, &listReq); err != nil {
 		c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("invalid request body: %v", err)})
 		return
 	}
+	if listReq.PageNumber <= 0 || listReq.PageSize <= 0 {
+		c.JSON(http.StatusBadRequest, gin.H{"error": "PageNumber and PageSize must be greater than 0"})
+		return
+	}
 
 	if listReq.Filter == nil {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/task/doubao/asset.go` around lines 276 - 297, The
HandleListAssets function needs to validate pagination parameters to prevent
invalid values from being sent to the upstream Volcengine API. After
unmarshaling the request body (after the UnmarshalBodyReusable call but before
the Marshal call), add validation to check that PageNumber and PageSize have
valid, non-zero values. If either parameter is missing or out of acceptable
range, return a BadRequest response with a clear error message indicating what
values are required, similar to how the invalid request body error is already
handled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@relay/channel/task/doubao/asset.go`:
- Around line 30-69: The PageNumber and PageSize fields in the ListAssetsRequest
struct are defined as non-pointer int64 types without omitempty tags, which
prevents distinguishing between absent values (that should be nil) and explicit
zero values. Change these two fields from int64 to *int64 and add omitempty to
their JSON tags, so they become json:"PageNumber,omitempty" and
json:"PageSize,omitempty" respectively, to align with the coding guidelines for
optional scalar fields in relay request DTOs like the other optional fields
(Filter, SortBy, SortOrder, ProjectName) already defined in the struct.

---

Nitpick comments:
In `@relay/channel/task/doubao/asset.go`:
- Around line 444-494: Add validation for pagination parameters in the
HandleListAssetGroups function. After unmarshaling the request body, validate
that PageNumber and PageSize are provided and within acceptable ranges before
proceeding with the API call. If either parameter is missing or out of range,
return a bad request response with an appropriate error message. This validation
should be similar to what is implemented in HandleListAssets and should occur
before the applyDefaults call.
- Around line 417-438: The HandleCreateAssetGroup function does not validate
that the required Name field is present in the CreateAssetGroupRequest struct.
Add a validation check immediately after calling common.UnmarshalBodyReusable to
ensure that req.Name is not empty, and if it is empty, return a clear error
response to the client with an appropriate HTTP status code (such as BadRequest)
before proceeding with the applyDefaults call and further processing.
- Around line 330-352: The HandleCreateAsset function does not validate required
fields before passing the request to the upstream API. Add validation logic
after unmarshaling the request body to check that the URL and AssetType fields
in CreateAssetRequest are not empty strings. If either field is missing, return
a http.StatusBadRequest response with a clear error message indicating which
required field is missing, similar to the existing error handling pattern in the
function. This validation should occur before calling applyDefaults to ensure
invalid requests fail fast with user-friendly error messages.
- Around line 276-297: The HandleListAssets function needs to validate
pagination parameters to prevent invalid values from being sent to the upstream
Volcengine API. After unmarshaling the request body (after the
UnmarshalBodyReusable call but before the Marshal call), add validation to check
that PageNumber and PageSize have valid, non-zero values. If either parameter is
missing or out of acceptable range, return a BadRequest response with a clear
error message indicating what values are required, similar to how the invalid
request body error is already handled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c0835726-ae3c-4a6e-a55e-8b5c8005bdfd

📥 Commits

Reviewing files that changed from the base of the PR and between e569474 and 86022dd.

📒 Files selected for processing (5)
  • controller/asset.go
  • model/option.go
  • relay/channel/task/doubao/asset.go
  • router/video-router.go
  • setting/system_setting/volc_asset.go

Comment on lines +30 to +69
type AssetFilter struct {
GroupIds []string `json:"GroupIds,omitempty"`
GroupType string `json:"GroupType" example:"AIGC"` // 可选,留空使用默认值(AIGC)
Statuses []string `json:"Statuses,omitempty"`
Name string `json:"Name,omitempty"`
}

type ListAssetsRequest struct {
Filter *AssetFilter `json:"Filter,omitempty"`
PageNumber int64 `json:"PageNumber"`
PageSize int64 `json:"PageSize"`
SortBy string `json:"SortBy,omitempty"`
SortOrder string `json:"SortOrder,omitempty"`
ProjectName string `json:"ProjectName,omitempty"` // 可选,留空使用默认值
}

type AssetError struct {
Code string `json:"Code,omitempty"`
Message string `json:"Message,omitempty"`
}

type AssetItem struct {
Id string `json:"Id"`
Name string `json:"Name"`
URL string `json:"URL"`
GroupId string `json:"GroupId"`
AssetType string `json:"AssetType" example:"Image" enums:"Image,Video,Audio"` // 素材类型:Image=图像, Video=视频, Audio=音频
Status string `json:"Status"`
Error AssetError `json:"Error,omitempty"`
ProjectName string `json:"ProjectName"`
CreateTime string `json:"CreateTime"`
UpdateTime string `json:"UpdateTime"`
}

type ListAssetsResponse struct {
Items []AssetItem `json:"Items"`
TotalCount int64 `json:"TotalCount"`
PageNumber int64 `json:"PageNumber"`
PageSize int64 `json:"PageSize"`
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there are validation patterns for pagination in similar handlers
rg -nP -A5 'PageNumber|PageSize' --type=go -g 'relay/**/*.go' -g '!asset.go'

Repository: QuantumNous/new-api

Length of output: 45


🌐 Web query:

Volcengine Asset API ListAssets PageNumber PageSize parameter requirements

💡 Result:

I couldn’t find (from the retrieved official sources) an authoritative Volcengine “Asset API / ListAssets” reference page that explicitly states the pagination parameter requirements for PageNumber and PageSize (e.g., min/max/default, whether page number is 1-based or 0-based). What I found instead: - There is a Volcengine “火山方舟-查询素材资产列表(ListAssets)” documentation page, but the content I retrieved does not include the specific PageNumber/PageSize constraint details needed to answer your question [1]. - A third-party mirror (Anyfast) documents a /volc/asset/ListAssets endpoint, but it also doesn’t include the PageNumber/PageSize constraint requirements in the retrieved material [2][3]. - Another Volcengine API (RDS for MySQL “ListResourcePackages”) shows pagination constraints (min page number 1; page size max 1000), but it is for a different API and I can’t apply those limits to ListAssets without confirmation [4]. To give you a precise, citation-backed answer, I need one of the following: 1) the exact Volcengine product/service name for “Asset API ListAssets” (e.g., 火山方舟/Seedance 2.0 素材库, 资产管理, 容器镜像仓库等), or 2) the specific API reference URL (or screenshot/text) where PageNumber and PageSize are defined. Once you share that, I can do a targeted re-search and extract the exact parameter rules for PageNumber/PageSize.

Citations:


🏁 Script executed:

# Search for ListAssetsRequest usage and validation
find relay/channel/task/doubao -type f -name "*.go" | head -20

Repository: QuantumNous/new-api

Length of output: 174


🏁 Script executed:

# Check if there's validation logic for pagination parameters
rg -A10 "ListAssetsRequest" relay/channel/task/doubao/ --type=go

Repository: QuantumNous/new-api

Length of output: 1668


🏁 Script executed:

# Look for how other relay channels handle pagination parameters
rg -B2 -A2 "PageNumber.*int|PageSize.*int" relay/ --type=go

Repository: QuantumNous/new-api

Length of output: 1868


🏁 Script executed:

# Check if there are similar API request structs to see patterns
rg "PageNumber|PageSize" relay/channel --type=go -B1 -A1

Repository: QuantumNous/new-api

Length of output: 1319


🏁 Script executed:

# Read the full handler function to see complete context around ListAssetsRequest usage
rg -B5 -A30 "listReq :=" relay/channel/task/doubao/asset.go --type=go

Repository: QuantumNous/new-api

Length of output: 45


🏁 Script executed:

# Check if there's any validation of PageNumber/PageSize values downstream
rg -B2 -A5 "PageNumber|PageSize" relay/channel/task/doubao/adaptor.go --type=go

Repository: QuantumNous/new-api

Length of output: 45


🏁 Script executed:

# Look for the actual upstream API call to see if defaults are applied
rg -B5 -A10 "ListAssets\|listReq" relay/channel/task/doubao/adaptor.go --type=go

Repository: QuantumNous/new-api

Length of output: 45


🏁 Script executed:

# Read the entire asset.go file to understand the full context
wc -l relay/channel/task/doubao/asset.go

Repository: QuantumNous/new-api

Length of output: 102


🏁 Script executed:

# Read asset.go in full or sections to understand ListAssetsRequest usage
cat -n relay/channel/task/doubao/asset.go | head -150

Repository: QuantumNous/new-api

Length of output: 5535


🏁 Script executed:

# Also check adaptor.go to see how requests are forwarded
cat -n relay/channel/task/doubao/adaptor.go

Repository: QuantumNous/new-api

Length of output: 13601


🏁 Script executed:

# Search for the handler function that parses ListAssetsRequest
rg -B2 -A50 "ListAssetsRequest" relay/channel/task/doubao/asset.go | head -100

Repository: QuantumNous/new-api

Length of output: 3522


🏁 Script executed:

# Check if there's validation of PageNumber or PageSize anywhere
rg "PageNumber|PageSize" relay/channel/task/doubao/asset.go -B2 -A2

Repository: QuantumNous/new-api

Length of output: 1028


Use pointer types with omitempty for optional pagination parameters.

PageNumber and PageSize in ListAssetsRequest (lines 39-40) and ListAssetGroupsRequest are non-pointer int64 fields without omitempty tags. Per coding guidelines, optional scalar fields in relay request DTOs must use pointer types with omitempty to distinguish between absent (nil) and explicit zero values.

The handler HandleListAssets does not validate these parameters or apply defaults. If the client omits these fields, they will unmarshal to 0 and be sent to the upstream Volcengine API without validation, potentially causing unexpected behavior if 0 is not a valid value.

Change these fields to *int64 with json:"PageNumber,omitempty" and json:"PageSize,omitempty" to preserve the distinction between absent and explicit zero values, consistent with how other optional fields (Filter, SortBy, SortOrder, ProjectName) are defined.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/task/doubao/asset.go` around lines 30 - 69, The PageNumber and
PageSize fields in the ListAssetsRequest struct are defined as non-pointer int64
types without omitempty tags, which prevents distinguishing between absent
values (that should be nil) and explicit zero values. Change these two fields
from int64 to *int64 and add omitempty to their JSON tags, so they become
json:"PageNumber,omitempty" and json:"PageSize,omitempty" respectively, to align
with the coding guidelines for optional scalar fields in relay request DTOs like
the other optional fields (Filter, SortBy, SortOrder, ProjectName) already
defined in the struct.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant