Repository navigation
Conversation
…#8034) Reveal invalid group settings in the existing JSON editor, focus the first invalid field, and share error handling across save and form submission. Preserve numeric-limit navigation and expose switch errors. Test with the production validation schema. Reject missing/null and non-scalar option values. Validate AutoGroups before single and bulk persistence, preserve runtime groups on parse failure, and roll back failed option writes before publishing memory state. Keep historical malformed text available for explicit correction instead of silently replacing it. Verification: frontend models and JSON editor suites passed (11 files, 103 tests); bunx --no-install tsgo -b passed (bun check -b is unavailable in this checkout); targeted oxlint, protected-header-safe formatting, gofmt and git diff --check passed. Backend: go test ./controller ./model ./setting -run 'Test(AutoGroupsOptionPersistence|UpdateOption|ValidateOptionValue|UpdateMaxTokenAutoGroups|RetiredThemeOption)' -count=1 -v passed with real SQLite 3.50.4, MySQL 26.7.0 and PostgreSQL 16.15 test databases.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Backend validation and persistence setting/auto_group.go, model/option.go, controller/option.go, controller/option_auto_group_test.go |
AutoGroups parsing rejects invalid JSON and arrays with non-string values. Option updates validate input and return database write errors before changing in-memory settings. Tests cover invalid inputs, write failures, and valid persistence. |
Shared ratio settings schemas web/src/features/system-settings/models/ratio-settings-schema.ts, web/src/features/system-settings/models/ratio-settings-card.tsx, web/src/features/system-settings/models/__tests__/group-settings.test.tsx |
Model and group validation schemas move into a shared module. The schemas validate JSON settings and field types, and the card and tests use them. |
Form error routing and feedback web/src/features/system-settings/models/group-ratio-form.tsx, web/src/features/system-settings/models/__tests__/group-settings.test.tsx |
Invalid submissions route to the relevant editor view and focus the first invalid field. The default-auto-group switches display validation messages. Tests cover invalid JSON and field values. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- QuantumNous/new-api#8035: It changes the group-pricing form validation path that this PR extends with shared schemas, error routing, and backend persistence handling.
Suggested reviewers: calcium-ion
Merge Risk: 
Minimal · up to e1f3d
-
No actionable issue identified in the reviewed changes; the PR is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue
#8034is directly linked and requires visible feedback when group-pricing validation blocks saving. The frontend now applies one invalid-submit handler to the save button and native form submission. The handler opens JSON mode for malformed JSON, selects the Auto section for the numeric limit case, and focuses the first invalid field. Both switch fields render validation messages. The shared group schema validates all listed JSON fields and requiresAutoGroupsto be a string array. Tests cover invalid values in six fields, invalid switch data, combined errors, focus, correction, and successful save. The backend validatesAutoGroupsbefore persistence and the targeted Go tests cover rejected malformed values and valid saves. The reported verification also records 103 frontend tests and the targeted Go tests on SQLite, MySQL, and PostgreSQL passing.
Full details: Out of Scope Changes check
-
Explanation
The changed files remain connected to issue
#8034. Schema extraction and shared error handling support the group-pricing validation fix. Backend type rejection,AutoGroupsvalidation, transactional writes, and rollback tests prevent invalid option persistence and stale in-memory state. No billing formula, relay, migration, or unrelated service changes are present. Historical<nil>values remain unchanged until an administrator corrects them, as stated in the current PR scope.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 7 functions across 8 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A rabbit checks the JSON rows,
And finds the fields that need a fix.
It hops to where the errors show,
Then waits for writes to safely stick.
The groups return in tidy strings,
While carrots cheer the saved settings.
Comment @coderabbitai help to get the list of available commands.
Resolve SQLite source paths before constructing file URIs. Resolve directory identities before sorting and acquiring locks so config aliases do not cause self-conflicts. Add relative backup/verify/restore and alias-lock regressions. Refs: QuantumNous/new-api#8076 (PR #8076) Refs: QuantumNous/new-api#8034 (issue #8034)
Use complete logical-channel transaction snapshots so central persistence rollback cannot be followed by an incremental undo that panics or removes existing data. Reject audit cursors when any portion of the original retained interval expires. Synchronize test writers after a second manager persists migration defaults, without weakening pending external-edit protection. Regression coverage includes first/existing logical creation, deletion and update failures, partial/full cursor eviction, and repeated single-writer mutations. Follow-up to soulteary/yunqi PR #105 review. Refs: QuantumNous/new-api #8076 QuantumNous/new-api#8076 Refs: QuantumNous/new-api #8034 QuantumNous/new-api#8034 Refs: QuantumNous/new-api #6673 QuantumNous/new-api#6673
Refs: QuantumNous/new-api #7953 QuantumNous/new-api#7953 Refs: QuantumNous/new-api #7951 QuantumNous/new-api#7951 Refs: QuantumNous/new-api #8076 QuantumNous/new-api#8076 Refs: QuantumNous/new-api #8034 QuantumNous/new-api#8034
Carry explicit management context through policy, preview, approval and removal into the atomic config persistence boundary. Retain compatible system wrappers and the variadic discovery revision guard. Correlate policy/approval domain history with the management operation ID. Add transaction rollback and human/background actor regressions plus real HTTP coverage of all four management mutation phases. Refs: QuantumNous/new-api #7953 QuantumNous/new-api#7953 Refs: QuantumNous/new-api #7951 QuantumNous/new-api#7951 Refs: QuantumNous/new-api #8076 QuantumNous/new-api#8076 Refs: QuantumNous/new-api #8034 QuantumNous/new-api#8034
Refs: QuantumNous/new-api #7953 QuantumNous/new-api#7953 Refs: QuantumNous/new-api #7951 QuantumNous/new-api#7951 Refs: QuantumNous/new-api #8076 QuantumNous/new-api#8076 Refs: QuantumNous/new-api #8034 QuantumNous/new-api#8034
Forward HTTP management context to the locked account transaction while retaining a fresh system-context wrapper for automatic discovery. Verify both account and individual discovery writes remain isolated from human actors. Refs: QuantumNous/new-api #7953 QuantumNous/new-api#7953 Refs: QuantumNous/new-api #7951 QuantumNous/new-api#7951 Refs: QuantumNous/new-api #8076 QuantumNous/new-api#8076 Refs: QuantumNous/new-api #8034 QuantumNous/new-api#8034
Commit configuration and bounded management audit atomically, retain explicit actor/operation identity through HTTP and domain transactions, and preserve separate system attribution for discovery. Regression tests, cross-review and full Verify CI passed, including retention/rollback fixes, model governance integration and isolated Redis readiness. Refs: QuantumNous/new-api#8076 QuantumNous/new-api#8076 Refs: QuantumNous/new-api#8034 QuantumNous/new-api#8034 Refs: QuantumNous/new-api#6673 QuantumNous/new-api#6673 Refs: QuantumNous/new-api#7953 QuantumNous/new-api#7953 Refs: QuantumNous/new-api#7951 QuantumNous/new-api#7951
docs: finalize community improvement batches and validation Document eight implemented capabilities, review fixes, exact commits, CI evidence and upstream correspondence. Preserve identity, Redis and evaluation boundaries, and provide the model governance lifecycle/API guide. All functional PRs were reviewed and merged after successful regression tests and Verify CI. The running checkout and services were not changed. Refs: QuantumNous/new-api issue #1730 QuantumNous/new-api#1730 Refs: QuantumNous/new-api issue #2841 QuantumNous/new-api#2841 Refs: QuantumNous/new-api issue #3240 QuantumNous/new-api#3240 Refs: QuantumNous/new-api PR #3345 QuantumNous/new-api#3345 Refs: QuantumNous/new-api issue #4328 QuantumNous/new-api#4328 Refs: QuantumNous/new-api PR #4329 QuantumNous/new-api#4329 Refs: QuantumNous/new-api PR #4492 QuantumNous/new-api#4492 Refs: QuantumNous/new-api PR #5431 QuantumNous/new-api#5431 Refs: QuantumNous/new-api PR #5791 QuantumNous/new-api#5791 Refs: QuantumNous/new-api PR #6264 QuantumNous/new-api#6264 Refs: QuantumNous/new-api PR #6583 QuantumNous/new-api#6583 Refs: QuantumNous/new-api PR #6620 QuantumNous/new-api#6620 Refs: QuantumNous/new-api PR #6673 QuantumNous/new-api#6673 Refs: QuantumNous/new-api issue #6972 QuantumNous/new-api#6972 Refs: QuantumNous/new-api PR #7028 QuantumNous/new-api#7028 Refs: QuantumNous/new-api issue #7951 QuantumNous/new-api#7951 Refs: QuantumNous/new-api issue #7952 QuantumNous/new-api#7952 Refs: QuantumNous/new-api PR #7953 QuantumNous/new-api#7953 Refs: QuantumNous/new-api PR #7955 QuantumNous/new-api#7955 Refs: QuantumNous/new-api issue #8034 QuantumNous/new-api#8034 Refs: QuantumNous/new-api PR #8076 QuantumNous/new-api#8076 Refs: QuantumNous/new-api issue #8123 QuantumNous/new-api#8123 Refs: QuantumNous/new-api PR #8124 QuantumNous/new-api#8124 Refs: QuantumNous/new-api issue #8232 QuantumNous/new-api#8232 Refs: QuantumNous/new-api PR #8233 QuantumNous/new-api#8233 Refs: QuantumNous/new-api issue #8295 QuantumNous/new-api#8295 Refs: QuantumNous/new-api PR #8296 QuantumNous/new-api#8296 Refs: QuantumNous/new-api PR #8350 QuantumNous/new-api#8350 Refs: QuantumNous/new-api PR #8357 QuantumNous/new-api#8357 Refs: QuantumNous/new-api PR #8363 QuantumNous/new-api#8363 Refs: #99 #99 Refs: #100 #100 Refs: #101 #101 Refs: #102 #102 Refs: #103 #103 Refs: #104 #104 Refs: #105 #105 Refs: #106 #106 Refs: #107 #107 Refs: #108 #108 Refs: #109 #109 Documentation Verify CI passed: https://github.com/soulteary/yunqi/actions/runs/45003986698
Agent
gpt-6-astra(provider:responses)Links
Closes #8034
User request
Out of scope — refuse
Open gate — do not open unless all are satisfied
Kind
Issue facts
PUT /api/option/请求,离开页面后修改丢失。AutoGroups为字面量<nil>时必现。/system-settings/billing/group-pricing。不涉及 relay。Change
Value,不再把它格式化为<nil>;拒绝非法AutoGroups,包括字面量<nil>。单项、批量更新均先校验再写数据库;写入失败回滚,不发布新的OptionMap值。解析失败保留运行时分组。<nil>不会自动迁移为[],保留原文供用户明确修正。Research
Duplicate / prior art
8034、AutoGroups in:title、group pricing in:title,并检查同名源分支。Docs and code
<nil>定义为合法配置。README.md的 Capabilities / Quick start:分组及定价属于管理配置。handleSubmit错误分支和后端 option 更新路径证明这是校验缺陷,不是配置使用问题。Alternatives considered
[]会隐式修改路由配置,未采用。Files
web/src/features/system-settings/models/group-ratio-form.tsxweb/src/features/system-settings/models/ratio-settings-card.tsx,ratio-settings-schema.tsweb/src/features/system-settings/models/__tests__/group-settings.test.tsxcontroller/option.go,model/option.go,setting/auto_group.gocontroller/option_auto_group_test.goBehavior
<nil>阻止提交却无可见反馈;无效值可能在返回错误前进入存储或内存。AutoGroups = {}导致的可视化渲染错误。Verification
以下为本提交完成时实际执行并观察的结果;发布草稿前核对了日志,未改代码或重跑无关测试。
web/:bun run test src/features/system-settings/models/__tests__ src/components/json-code-editor/__tests__:11 个文件、103 个测试通过。修复前新增的 7 个交互回归失败,修复后通过。web/:bunx --no-install tsgo -b:通过。bun check -b缺少check入口,使用已安装的 tsgo。TEST_MYSQL_DSN、TEST_POSTGRES_DSN后:git diff --check通过。Risks
UpdateOption的通用数据库写入路径改为事务并传播数据库错误。AutoGroups = {}的可视化渲染错误不在本修复范围。Scope check
Summary by CodeRabbit