Repository navigation
ONE-471: PUT /api/admin/settings 接受 columns=0(0–12,复杂档) - #13
Merged
Merged
Conversation
- worker: columns 校验范围 1–12 → 0–12,错误文案同步 "columns must be between 0 and 12";0 原样存入/返回,不转默认值 - docs/api-contract.md: 站点设置 columns 允许值 0–12,注明 0 = 未配置 - 注释同步: worker/src/types.ts、web/src/lib/types.ts - 新增 worker/test/settings.test.ts: 0 往返、1–12 通过、越界与非数字仍 400
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.
ONE-471 · 后端修复:
PUT /api/admin/settings接受columns=0(复杂档)问题
GET /api/admin/settings对未配置的库返回columns: 0(0 = 未配置),但PUT /api/admin/settings只接受 1–12,把读到的值原样提交会 400columns must be between 1 and 12。新库(fresh D1)settings.columns=0,会挡住「站点设置」整体保存(含 Stage2 新增的背景/Logo)。这是后端校验的往返不一致缺陷。改动
worker/src/routes/admin.ts:columns校验从1–12放宽为0–12,错误文案改为columns must be between 0 and 12;0原样存入/返回,不转默认值。其他字段校验与其他端点行为未动。docs/api-contract.md:站点设置部分columns(1–12)→columns(0–12),并注明0= 未配置、原样往返、越界 400 文案。worker/src/types.ts、web/src/lib/types.ts:仅同步 columns 注释文字,前端逻辑未改。worker/test/settings.test.ts(新增):columns=0往返(GET 0 → PUT 0 → GET 0,且落库为"0")、0 与其他字段一起写入、1–12 全部通过、-1/13/100与非数字仍 400 且不覆盖已存值。不新增依赖、不改 schema、不迁移数据、不碰 R2/资产代码。
测试
pnpm test:9 files / 97 tests 全通过(新增 settings.test.ts 5 例;把校验临时改回1–12时其中 4 例会红,证明确实覆盖该缺陷)。pnpm typecheck、pnpm build、pnpm format:check:通过。pnpm lint在本地被环境包装成 "ESLint output (JSON parse failed…)" 且退出码 1,git stash到未改动的 main 上同样复现(非本改动引入);直接跑biome lint .退出码 0,仅 28 条既有 warning,均不在本改动文件内。以 CI 的pnpm lint为准。本地 dev 自验(
wrangler dev+ 本地 D1,全新库)