Safe audit cleanups: env defaults, pagination 500, log redaction, forbidOnly#698
Merged
Conversation
…bidOnly Low-risk fixes from the repo audit (no CI/DB/provider surface): - .env.example: OPENAI_MAX_OUTPUT_TOKENS 4000 -> 16000 and OPENAI_STRONG_REASONING_EFFORT high -> medium, aligning the template with the corrected env.ts defaults (both shipped the known GEN-C1 answer-loss and safety-critical answer-starvation values). Also document the anonymous-upload gates (NEXT_PUBLIC_PUBLIC_UPLOADS_ENABLED / PUBLIC_WORKSPACE_OWNER_ID). - src/app/api/documents/route.ts: an out-of-range pagination offset now returns an empty page instead of a 500 (PostgREST PGRST103 is a valid empty page). - src/lib/rag.ts: route the answer-payload parse-error log through safeErrorLogDetails so a malformed-JSON snippet can't reach logs unredacted, matching every other server error path. - playwright.config.ts: forbidOnly on CI so a stray test.only can't silently narrow the suite while the required check stays green. Verified offline: lint + prettier clean on changed files, typecheck clean on changed files, 9 document-route tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019UQUcNriJUVSGRhWz794RQ
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Contributor
📝 WalkthroughWalkthroughThe changes update OpenAI and public-upload environment defaults, handle empty document pages from PostgREST, prevent focused Playwright tests in CI, and sanitize structured-answer parse failure logs. ChangesRuntime safeguards
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
BigSimmo
marked this pull request as ready for review
July 17, 2026 05:44
BigSimmo
enabled auto-merge
July 17, 2026 05:44
12 tasks
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.
Summary
The low-risk cleanups from the repository audit — no CI, DB/migration, or provider surface (that's why they're separated from the hardening work in #696).
.env.exampledefaults aligned withenv.ts:OPENAI_MAX_OUTPUT_TOKENS4000 → 16000 andOPENAI_STRONG_REASONING_EFFORThigh → medium. The template was shipping the exact valuesenv.tsdocuments as the confirmed GEN-C1 answer-loss default and the safety-critical answer-starvation setting, so anyone copying it reintroduced those regressions. Also documented the anonymous-upload gates (NEXT_PUBLIC_PUBLIC_UPLOADS_ENABLED/PUBLIC_WORKSPACE_OWNER_ID), which gate an unauthenticated write path and were undocumented.src/app/api/documents/route.ts: an out-of-range paginationoffsetreturned HTTP 500 (PostgRESTPGRST103was thrown). It now returns an empty page — the correct contract for paging past the end.src/lib/rag.ts: the answer-payload parse-error log now routes throughsafeErrorLogDetails(like every other server error path), so a malformed-JSON snippet of the generated answer can't reach logs unredacted.playwright.config.ts:forbidOnlyon CI, so a straytest.onlycan't silently narrow the suite (and skip the release matrix) while the required check still reports green.Verification
Run locally and offline — no OpenAI/Supabase/live-DB/CI calls.
lintandprettier --checkclean on all changed filestypecheckclean on the changed files (rag.ts,documents/route.ts,playwright.config.ts)document-flow-routes,document-mutation-routes)npm run verify:pr-local(full) not run — its build/full-typecheck need devDeps not installed in this container; the offline constituents were run individually.Clinical Governance Preflight
Touches answer-generation config and a document API route.
Clinical KB Database— unchangedNotes
main.🤖 Generated with Claude Code
https://claude.ai/code/session_019UQUcNriJUVSGRhWz794RQ
Generated by Claude Code
Summary by CodeRabbit
Bug Fixes
Configuration
Tests