fix: align Zod contracts with runtime data - #7499
Conversation
Coverage Report
File CoverageNo changed files found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6be6bec72b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (totalPoints === null || surplusPoints === null) { | ||
| await teamPointCache.clear(teamId); | ||
| } else { | ||
| await teamPointCache.set({ teamId, totalPoints, surplusPoints }); |
There was a problem hiding this comment.
Keep point-cache refresh off the response critical path
This change awaits a Redis write or two-key deletion on every getTeamPlanStatus call, whereas the previous cache refresh was intentionally fire-and-forget. In the inspected upload/presign and team-plan-status request paths, a slow or unavailable Redis instance will now add its timeout latency even though the MongoDB result is already available and the cache implementation treats writes as best-effort; deployments without subscription limits also perform and await the deletion on every call. Refresh or clear the cache without blocking the business response.
Useful? React with 👍 / 👎.
|
✅ Build Successful - Preview fastgpt Image for this PR: 🕒 Time: 2026-08-12 00:36:22 (UTC+8) |
There was a problem hiding this comment.
Pull request overview
This PR tightens runtime producers to match stricter Zod/OpenAPI contracts by normalizing legacy/unlimited plan semantics, improving request input validation, and aligning dataset/system-model payload shapes across backend and frontend.
Changes:
- Switched password-related API routes to use
parseApiInputand extended API tests to cover malformed bodies/injection-shaped inputs. - Normalized team plan “unlimited” values to
nullacross wallet status + permission checks, and updated UI to handlenullquotas safely. - Aligned dataset training
dataIdserialization withObjectIdSchemaand refined system model validation via a discriminated union.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| projects/app/test/api/support/user/account/updatePasswordByOld.test.ts | Adds assertions for parseApiInput error handling and tightens request typing in tests. |
| projects/app/test/api/support/user/account/resetExpiredPsw.test.ts | Extends malformed-body coverage and reuses a direct handler import for parse-error scenarios. |
| projects/app/test/api/core/dataset/training/getTrainingError.test.ts | Ensures dataId is present in fixtures and asserted as serialized string in responses. |
| projects/app/test/api/core/dataset/training/getDatasetTrainingError.test.ts | Adds dataId fixtures + asserts string serialization for grouped error items. |
| projects/app/src/pages/api/support/user/account/updatePasswordByOld.ts | Routes body validation through parseApiInput for consistent API-boundary errors. |
| projects/app/src/pages/api/support/user/account/resetExpiredPsw.ts | Routes body validation through parseApiInput for consistent API-boundary errors. |
| projects/app/src/pages/api/core/dataset/training/getDatasetTrainingError.ts | Removes response casting so response typing relies on schema parsing/aggregation results. |
| projects/app/src/pages/account/info/index.tsx | Updates plan usage calculations/UI to correctly handle null (unlimited) quotas. |
| projects/app/src/pageComponents/dashboard/TeamPlanStatusCard.tsx | Handles unlimited points display and fixes hide/show logic with time-based re-rendering. |
| projects/app/src/components/support/wallet/NotSufficientModal/index.tsx | Updates points usage display/progress behavior to support null quotas. |
| packages/service/test/support/wallet/sub/utils.test.ts | Adds coverage for legacy plan normalization, fractional points, and null-unlimited normalization. |
| packages/service/test/support/permission/teamLimit.test.ts | Adds tests confirming null quotas disable limits for points/dataset checks. |
| packages/service/support/wallet/sub/utils.ts | Implements unlimited normalization to null and updates cache behavior accordingly. |
| packages/service/support/permission/teamLimit.ts | Updates limit checks to treat null quotas as unlimited (no restriction). |
| packages/service/core/ai/config/utils.ts | Keeps embedding weight in desensitized system models by not blanking it out. |
| packages/service/common/api/frequencyLimit.ts | Wraps rate-limit failure messages in UserError for consistent error handling. |
| packages/global/test/openapi/common/team.test.ts | Adds contract tests for fractional points and null unlimited plan values. |
| packages/global/support/wallet/sub/type.ts | Updates plan schemas to allow fractional points and null unlimited values in client status. |
| packages/global/openapi/common/system/api.ts | Switches system model schema to discriminatedUnion('type', ...). |
| packages/global/core/dataset/type.ts | Validates/serializes training dataId via ObjectIdSchema. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| it('should reject newPsw as non-string (injection guard)', async () => { | ||
| vi.stubEnv('PASSWORD_EXPIRED_MONTH', '1'); | ||
| const resetExpiredPswApi = await loadResetExpiredPswApi(); | ||
|
|
||
| const twoMonthsAgo = new Date(); | ||
| twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - 2); | ||
| await MongoUser.findByIdAndUpdate(testUser._id, { | ||
| passwordUpdateTime: twoMonthsAgo | ||
| }); | ||
|
|
|
✅ Docs Preview Deployed! 🔗 👀 Click here to visit preview 🕒 Time: 2026-08-12 10:36:55 (UTC+8) |
|
✅ Admin Preview Image Ready! 🕒 Time: 2026-08-12 00:33:34 (UTC+8) |
What changed
maxTemperature: nullafter the final runtime model type is resolvedWhy
PR #7493 enabled response parsing and exposed mismatches between strict Zod contracts and historical or runtime values. These changes fix producers and stored data instead of broadly loosening response schemas. Runtime reload also merged plugin
nullvalues back into otherwise clean database configurations, so normalization now runs after the final model type is known.Model cleanup
Call
POST /api/admin/dataClean/cleanSystemModelConfigswith{"dryRun":true,"sampleLimit":20}first, then repeat withdryRun:falseafter reviewinginvalidSamples. A formal run always rebuilds the system model cache, even whenupdatedis0.functionCallremains optional and a missing embeddingweightdefaults to0.Validation
maxTemperaturepnpm --filter @fastgpt/app typecheckPaired enterprise change