Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public Result throwExceptionIfError() {
}
}

@Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
@Param(required = false, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String volumeUuid;

@Param(required = false)
public java.util.List<String> volumeUuids;
Comment on lines +28 to +32
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

缺少 volumeUuid 与 volumeUuids 的互斥验证逻辑

volumeUuid 改为可选并新增 volumeUuids 后,当前实现无法保证至少提供其中一个参数。如果两个参数都为空,迁移操作将无法执行,可能导致运行时错误或需要在服务端额外验证。

建议:

  • 在 SDK Action 层面添加参数验证逻辑,确保 volumeUuidvolumeUuids 至少提供一个
  • 或者在类级别添加注释说明这两个参数的互斥关系和验证要求
🤖 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 `@sdk/src/main/java/org/zstack/sdk/PrimaryStorageMigrateVolumeAction.java`
around lines 28 - 32, The PrimaryStorageMigrateVolumeAction class now exposes
both volumeUuid and volumeUuids but lacks validation to ensure at least one is
provided; add a validation step in the action (e.g., a validate() method invoked
before request assembly or inside the existing call/execute path) that checks
fields volumeUuid and volumeUuids and throws/returns a clear parameter error if
both are null/empty, or alternatively document their
mutual-exclusion/requirement at class-level if you prefer not to validate in
code; reference the class PrimaryStorageMigrateVolumeAction and the fields
volumeUuid and volumeUuids when implementing this check.


Comment on lines +28 to +33
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

批量参数已放开,但当前 URL 仍硬依赖 volumeUuid,会导致批量场景不可达。

Line 28 把 volumeUuid 改为可选,Line 31 新增 volumeUuids,但 getRestInfo() 仍使用 /primary-storage/volumes/{volumeUuid}/actions。这样在仅传 volumeUuids 时,路径变量无法可靠组装,SDK 合约前后不一致。建议统一为不依赖单个 volumeUuid 的路由(或拆分单卷/批量两个 Action,保持各自路径与参数契约一致)。

🤖 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 `@sdk/src/main/java/org/zstack/sdk/PrimaryStorageMigrateVolumeAction.java`
around lines 28 - 33, The REST path in PrimaryStorageMigrateVolumeAction still
embeds a single volumeUuid while the class now accepts both volumeUuid and
volumeUuids, causing batch calls to fail; update the getRestInfo()
implementation to use a non-instance path that does not require the {volumeUuid}
path variable (e.g. switch to a collection-level route like
/primary-storage/volumes/actions) and ensure request serialization uses
volumeUuids when provided (or alternatively split into two Actions: one that
keeps volumeUuid and its current path and one new
BatchPrimaryStorageMigrateVolumesAction that uses volumeUuids and a collection
route); modify getRestInfo() and any routing-related metadata accordingly to
make the parameter/route contract consistent with the volumeUuid and volumeUuids
fields.

@Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String dstPrimaryStorageUuid;

Expand Down