Linus 修复: 空 list JSON 序列化成 [] + seed.sh curl 续行

Linus 视角问题: ClusterRepo.List / AuditRepo.List 在空 list 时
返 nil, encoding/json 默认序列化成 null, 不是 []。
LLM/前端期望一致空数组语义。

- internal/storage/cluster_repo.go: List 返回前 out = []*cluster.Cluster{}
- internal/audit/repo.go: List 返回前 out = []*Entry{}

scripts/seed.sh curl 续行 bug: 在 set -euo pipefail 下 \\ 续行
被解析成多行, curl 收到混乱 argv 报 "URL rejected: Bad hostname"。
改为单行 + backslash 续行在 bash 中更稳。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-10 17:24:40 +08:00
co-authored by Claude
parent d6dd2b846f
commit 77d8bae503
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -102,6 +102,10 @@ func (r *Repo) List(ctx context.Context, limit int) ([]*Entry, error) {
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("audit: rows: %w", err)
}
if out == nil {
// Force empty array (not null) in JSON.
out = []*Entry{}
}
return out, nil
}