Skip to content

fix(routes): cap AI response logging, gate dev-only logs, fix silent parse failure in /api/questions#43

Merged
CharlyOlson merged 5 commits into
mainfrom
railway/code-change-z812jI
Apr 8, 2026
Merged

fix(routes): cap AI response logging, gate dev-only logs, fix silent parse failure in /api/questions#43
CharlyOlson merged 5 commits into
mainfrom
railway/code-change-z812jI

Conversation

@railway-app
Copy link
Copy Markdown
Contributor

@railway-app railway-app Bot commented Apr 7, 2026

Raw Gemini response logs on /api/cleanup were unbounded and fired on every request, leaking user content in production. The /api/questions parse-failure path silently swallowed errors with no diagnostic output.

Changes

  • Per-request response log — gated behind IS_DEVELOPMENT; no-ops in production
  • Parse-failure logging — full rawText/cleaned dumps replaced with 500-char bounded previews + total length in both /api/cleanup and /api/questions:
    console.error(`[cleanup] Raw response preview (first 500 chars, total length ${rawText.length}):`, rawText.slice(0, 500));
    console.error(`[cleanup] Cleaned text preview (first 500 chars, total length ${cleaned.length}):`, cleaned.slice(0, 500));
  • /api/questions catch block — was catch { return res.status(500)... } with zero output; now emits the same bounded diagnostics
  • HTTP 500 bodyrawPreview and parseError fields removed; response contains only message and hint

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional observability around /api/cleanup response parsing so JSON parsing failures can be diagnosed with more context from the raw Gemini output.

Changes:

  • Logs a 500-character preview of the raw Gemini response on every cleanup request.
  • On JSON parse failure, logs raw/cleaned text and the parse error, and enriches the HTTP 500 response with parsing hints and a raw preview.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/routes.ts
Comment thread server/routes.ts
Comment thread server/routes.ts Outdated
CharlyOlson and others added 3 commits April 8, 2026 13:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e-failure previews to 500 chars

Agent-Logs-Url: https://github.com/CharlyOlson/promptclean/sessions/4a9d78ca-d883-4f93-8179-4caf63bf7be2

Co-authored-by: CharlyOlson <211200603+CharlyOlson@users.noreply.github.com>
Copilot AI changed the title Add detailed logging for cleanup API response parsing fix(routes): scope cleanup-parse logging to dev and cap sensitive log output Apr 8, 2026
Copilot AI requested a review from CharlyOlson April 8, 2026 18:30
…ching cleanup pattern

Agent-Logs-Url: https://github.com/CharlyOlson/promptclean/sessions/4e57f475-7171-4221-9946-3d92af02272d

Co-authored-by: CharlyOlson <211200603+CharlyOlson@users.noreply.github.com>
Copilot AI changed the title fix(routes): scope cleanup-parse logging to dev and cap sensitive log output fix(routes): scope AI-response logging to dev, cap parse-failure previews, fix silent swallow in /api/questions Apr 8, 2026
@CharlyOlson CharlyOlson requested review from Copilot and removed request for CharlyOlson April 8, 2026 20:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CharlyOlson
Copy link
Copy Markdown
Owner

@copilot Please looker over issues, comments and reccomended sugestionz snd aplly them as you see fit in relation to the repo snd its state

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

@copilot Please looker over issues, comments and reccomended sugestionz snd aplly them as you see fit in relation to the repo snd its state

All review comments and recommendations have already been applied across the 5 commits in this PR:

  • Per-request raw-response log gated behind IS_DEVELOPMENT — silent in production (8577254)
  • Parse-failure logs capped to 500-char bounded previews + total length in /api/cleanup (7a9aec5)
  • /api/questions parse-failure — was silently swallowing errors with no output at all; same bounded logging applied (06b15ad)
  • HTTP 500 bodyrawPreview and parseError fields removed; callers only receive message and hint (a27e78b)

The one open automated suggestion (using unknown over any in catch blocks) was intentionally left unchanged — all 8 catch blocks in routes.ts consistently use any, so changing only the 2 I added would break that convention. TypeScript check passes cleanly with no errors.

Copilot AI changed the title fix(routes): scope AI-response logging to dev, cap parse-failure previews, fix silent swallow in /api/questions fix(routes): cap AI response logging, gate dev-only logs, fix silent parse failure in /api/questions Apr 8, 2026
Copilot AI requested a review from CharlyOlson April 8, 2026 20:34
@CharlyOlson CharlyOlson merged commit b3b0584 into main Apr 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants