fix(api): preserve owner-close ai-review setting - #1583
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1583 +/- ##
=======================================
Coverage 95.46% 95.46%
=======================================
Files 202 202
Lines 21839 21840 +1
Branches 7885 7886 +1
=======================================
+ Hits 20849 20850 +1
Misses 414 414
Partials 576 576
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review — safe to merge
✅ Approved — safe to merge Review summary
Nits — 2 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. Changes `closeOwnerAuthors` from `.default(false)` to `.optional()` and uses `??` to fall back to `current.closeOwnerAuthors` when the field is omitted — a correct, minimal fix for the accidental-reset bug. The `??` operator correctly distinguishes `undefined` (omitted) from an explicit `false`, so a caller that deliberately disables the flag is still honored. The regression test seeds the flag to `true`, issues a real PUT without the field, and asserts both the response and the DB row — this is a genuine integration test on the production code path, not a fabricated scenario. Nits (2)
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Motivation
closeOwnerAuthorsflag tofalsewhen callers omitted the new field because the Zod schema defaulted it tofalseand the handler unconditionally persisted that value.Description
closeOwnerAuthorsas optional instead of defaulting tofalseby changing the schema tocloseOwnerAuthors: z.boolean().optional()insrc/api/routes.ts.closeOwnerAuthorsvalue when the maintainer AI-review update omits the field by persistingparsed.data.closeOwnerAuthors ?? current.closeOwnerAuthorsinsrc/api/routes.ts.preserves closeOwnerAuthors when an AI-review update omits ittotest/unit/routes-ai-byok.test.tsthat seedscloseOwnerAuthors: true, issues an AI-reviewPUTwithout the field, and verifies the value remainstrue.Testing
git diff --checkandnpm run typecheck, both succeeded locally with no new type errors.npx vitest run test/unit/routes-ai-byok.test.tsand all tests in that file passed (20/20).npm run ui:openapiwhich regeneratedapps/gittensory-ui/public/openapi.jsonsuccessfully.npm run test:coveragebut coverage remapping failed after tests passed due to an upstream dependency mismatch (js-tokens@4.0.0vsast-v8-to-istanbulneedingjs-tokens@^10.0.0) producingTypeError: jsTokens is not a function, andnpm audit --audit-level=moderatecould not complete due to a registry 403; the functional unit tests and typecheck are green.Codex Task