feat: support bare JSON array credential import - #854
Merged
Conversation
Accept top-level JSON arrays in credential import files, the common
export shape of batch registration tools.
- decoder: per-element validation with indexed errors, limit pre-check
- web/console: reserve '[' as JSON prefix, fix silent plain-text import
- sync: deterministic {"sso_token": ...} payload and UTF-8 guard
(cherry picked from commit 03ece5a)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
有些 Grok build 凭证文件是顶层 JSON 数组形态(
[{...}, {...}]),此前在管理后台导入会报「第 1 行必须是 JSON 对象」,用户需改成{"accounts": [...]}包装或逐行 JSONL。本次让三种 Provider(Build / Web / Console)直接支持裸数组导入。改动内容
解码器新增数组分支(
infra/provider/import_json.go,三端共用)null放行,错误精确到「数组起始行 + 第 N 个元素」序号web/console 导入入口「[」保留前缀(
web/import.go、console/import.go)Web→Console 内部同步加固(
application/account/service.go){"sso_token": ...}固定 JSON 形态调用解析器,与 token 内容形态解耦json.Marshal静默改写为 U+FFFD 的非法输入兼容性
accounts包装 / JSONL 连续对象)行为不变[]、无逗号松散数组(明确报错)均按预期处理provider字段语义沿用各 Provider 现有 normalize 规则,无新增校验面测试
新增约 30 个测试,覆盖:
go test ./...与go vet ./...全绿。