Skip to content

fix(ai): add @AdminOnlyTag to SYNC_AI_METADATA to hide internal system tag#3354

Open
MatheMatrix wants to merge 1 commit into5.5.6from
sync/ye.zou/fix/ZSTAC-74908
Open

fix(ai): add @AdminOnlyTag to SYNC_AI_METADATA to hide internal system tag#3354
MatheMatrix wants to merge 1 commit into5.5.6from
sync/ye.zou/fix/ZSTAC-74908

Conversation

@MatheMatrix
Copy link
Owner

Resolves: ZSTAC-74908

Target: 5.5.6

sync from gitlab !9184

…m tag from non-admin users

ZSTAC-74908

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

概览

两个查询构建器类现在在排序时添加了 UUID 作为次级排序字段。当按非 UUID 字段排序时,会自动追加 UUID ASC 作为平局断路器;当未指定排序且非计数查询时,添加默认的 UUID ASC 排序。

变更

数据组 / 文件 摘要
查询排序改进
search/src/main/java/org/zstack/query/MysqlQueryBuilderImpl3.java, search/src/main/java/org/zstack/query/QueryFacadeImpl.java
在 ORDER BY 子句中添加 UUID 作为次级排序字段,确保排序的稳定性。当按非 UUID 字段排序时追加 UUID ASC 作为平局断路器;未指定排序且非计数查询时添加默认 UUID ASC 排序。

预期代码审查工作量

🎯 2 (简单) | ⏱️ ~10 分钟

诗歌

🐰 啊,排序的小兔子,欢呼雀跃!
UUID 作为钥匙,打破了平局的困境,
每条记录都找到了自己的位置,
稳定有序,如同春日的樱花。
查询如箭,精准而稳健!


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 3 warnings)
Check name Status Explanation Resolution
Title check ❌ Error 标题超过72字符限制(74字符),且描述内容与实际变更不符。变更内容是关于UUID排序的tiebreaker逻辑,与标题描述的AI元数据标签无关。 标题需要符合格式要求(<=72字符)并准确反映实际变更内容,例如调整为关于排序逻辑的描述。
Description check ⚠️ Warning 描述内容与实际代码变更不相关。变更涉及UUID排序tiebreaker逻辑,但描述仅提及AI元数据标签和JIRA号,未说明实际改动。 更新描述以准确反映实际变更:修改查询排序逻辑以添加UUID tiebreaker确保排序稳定性。
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.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (9 files):

⚔️ conf/db/upgrade/V5.5.6__schema.sql (content)
⚔️ identity/src/main/java/org/zstack/identity/QuotaUtil.java (content)
⚔️ longjob/src/main/java/org/zstack/longjob/LongJobManagerImpl.java (content)
⚔️ network/src/main/java/org/zstack/network/service/DhcpExtension.java (content)
⚔️ plugin/applianceVm/src/main/java/org/zstack/appliancevm/ApplianceVmFacadeImpl.java (content)
⚔️ plugin/flatNetworkProvider/src/main/java/org/zstack/network/service/flat/FlatUserdataBackend.java (content)
⚔️ sdk/src/main/java/org/zstack/sdk/GpuAllocateStatus.java (content)
⚔️ search/src/main/java/org/zstack/query/MysqlQueryBuilderImpl3.java (content)
⚔️ search/src/main/java/org/zstack/query/QueryFacadeImpl.java (content)

These conflicts must be resolved before merging into 5.5.6.
Resolve conflicts locally and push changes to this branch.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/ye.zou/fix/ZSTAC-74908
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch sync/ye.zou/fix/ZSTAC-74908
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@search/src/main/java/org/zstack/query/MysqlQueryBuilderImpl3.java`:
- Around line 736-741: Replace the Chinese comments in MysqlQueryBuilderImpl3
near the code that appends ordering (the block using variables ret, entityName,
msg.getSortBy(), msg.getSortDirection(), and msg.isCount()) with English
comments; specifically change the comment at the branch that adds uuid as a
tiebreaker to something like "append uuid as tiebreaker to ensure stable
ordering" and change the comment at the branch that adds default ordering when
no sort field is provided to something like "add default ordering by uuid when
no sort field is specified."

In `@search/src/main/java/org/zstack/query/QueryFacadeImpl.java`:
- Around line 489-494: Replace the Chinese comments on the block that appends
ordering to the query with English comments: change the comment before the
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(),
msg.getSortDirection())) to something like "add uuid as a tiebreaker to ensure
stable ordering" and change the comment before the sb.add("order by uuid asc")
in the !msg.isCount() branch to "apply default ordering when no sort field
provided"; locate these near the code that calls sb.add and references
msg.getSortBy(), msg.getSortDirection(), and msg.isCount() and update only the
comment text to English.

Comment on lines +736 to +741
// 追加 uuid 作为 tiebreaker,确保排序稳定
ret = String.format("%s order by %s.%s %s, %s.uuid ASC", ret, entityName, msg.getSortBy(), msg.getSortDirection().toUpperCase(), entityName);
}
} else if (!msg.isCount()) {
// 无排序字段时添加默认排序
ret = String.format("%s order by %s.uuid ASC", ret, entityName);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

注释应使用英文,不应包含中文。

根据编码规范,代码中不应有中文,包括注释。请将第 736 行和第 740 行的中文注释改为英文。

建议修复
                         } else {
-                            // 追加 uuid 作为 tiebreaker,确保排序稳定
+                            // Append uuid as tiebreaker to ensure stable sorting
                             ret = String.format("%s order by %s.%s %s, %s.uuid ASC", ret, entityName, msg.getSortBy(), msg.getSortDirection().toUpperCase(), entityName);
                         }
                     } else if (!msg.isCount()) {
-                        // 无排序字段时添加默认排序
+                        // Add default sorting when no sortBy is specified
                         ret = String.format("%s order by %s.uuid ASC", ret, entityName);

As per coding guidelines: "代码里不应当有有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写"

🤖 Prompt for AI Agents
In `@search/src/main/java/org/zstack/query/MysqlQueryBuilderImpl3.java` around
lines 736 - 741, Replace the Chinese comments in MysqlQueryBuilderImpl3 near the
code that appends ordering (the block using variables ret, entityName,
msg.getSortBy(), msg.getSortDirection(), and msg.isCount()) with English
comments; specifically change the comment at the branch that adds uuid as a
tiebreaker to something like "append uuid as tiebreaker to ensure stable
ordering" and change the comment at the branch that adds default ordering when
no sort field is provided to something like "add default ordering by uuid when
no sort field is specified."

Comment on lines +489 to +494
// 追加 uuid 作为 tiebreaker,确保排序稳定
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
}
} else if (!msg.isCount()) {
// 无排序字段时添加默认排序
sb.add("order by uuid asc");
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

注释应使用英文,不应包含中文。

根据编码规范,代码中不应有中文,包括注释。请将第 489 行和第 493 行的中文注释改为英文。

建议修复
         } else {
-                // 追加 uuid 作为 tiebreaker,确保排序稳定
+                // Append uuid as tiebreaker to ensure stable sorting
                 sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
             }
         } else if (!msg.isCount()) {
-            // 无排序字段时添加默认排序
+            // Add default sorting when no sortBy is specified
             sb.add("order by uuid asc");

As per coding guidelines: "代码里不应当有有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写"

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 追加 uuid 作为 tiebreaker,确保排序稳定
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
}
} else if (!msg.isCount()) {
// 无排序字段时添加默认排序
sb.add("order by uuid asc");
// Append uuid as tiebreaker to ensure stable sorting
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
}
} else if (!msg.isCount()) {
// Add default sorting when no sortBy is specified
sb.add("order by uuid asc");
🤖 Prompt for AI Agents
In `@search/src/main/java/org/zstack/query/QueryFacadeImpl.java` around lines 489
- 494, Replace the Chinese comments on the block that appends ordering to the
query with English comments: change the comment before the
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(),
msg.getSortDirection())) to something like "add uuid as a tiebreaker to ensure
stable ordering" and change the comment before the sb.add("order by uuid asc")
in the !msg.isCount() branch to "apply default ordering when no sort field
provided"; locate these near the code that calls sb.add and references
msg.getSortBy(), msg.getSortDirection(), and msg.isCount() and update only the
comment text to English.

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.

2 participants