Skip to content

fix(tools): sanitize database execution errors - #6645

Merged
TheodoreSpeaks merged 3 commits into
stagingfrom
fix/timeout-query
Aug 12, 2026
Merged

fix(tools): sanitize database execution errors#6645
TheodoreSpeaks merged 3 commits into
stagingfrom
fix/timeout-query

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Log redacted Drizzle diagnostics and return a generic caller-facing database error
  • Retry transient database failures during the read-only tool permission preflight
  • Preserve cancellation precedence and fail fast for non-transient database errors

Type of Change

  • Bug fix

Testing

  • 154 targeted tests passed
  • TypeScript type-check passed
  • Lint and block-registry validation passed
  • All 25 audits passed

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 12, 2026 10:19pm

Request Review

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes sit on the central executeTool path (permission preflight and error surfacing), but behavior is tightened for security (no SQL leakage) and resilience (limited retries).

Overview
Tool execution now wraps permission preflight in assertToolPermissionsWithRetry: up to three attempts with jittered backoff when assertPermissionsAllowed fails with a retryable DrizzleQueryError, while honoring the execution AbortSignal (cancellation wins over a concurrent DB failure).

When tool execution fails with a DrizzleQueryError, callers get a generic message (An internal error occurred while executing the tool. Please try again.) instead of SQL or bind values. Server logs use describeError for a redacted cause chain (e.g. params: [redacted]) and avoid logging raw stacks for those failures.

Tests mock assertPermissionsAllowed via a hoisted spy and cover retry success, exhausted retries, non-transient schema errors, and abort-vs-DB-error behavior.

Reviewed by Cursor Bugbot for commit c93972b. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents database permission-preflight failures from exposing SQL, bound parameters, or raw stacks while retaining redacted diagnostics and retrying transient failures.

  • Adds bounded retries for transient Drizzle failures during tool permission checks.
  • Returns a generic caller-facing database error and logs a sanitized cause chain.
  • Adds regression coverage for retry exhaustion, non-transient errors, cancellation, and sensitive-data redaction.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported raw-stack disclosure is removed from the database-error logging path, and the import-order report was invalidated by the established repository convention.

Important Files Changed

Filename Overview
apps/sim/tools/index.ts Adds permission-preflight database retries and replaces raw database error metadata with sanitized diagnostics and a generic caller-facing message.
apps/sim/tools/index.test.ts Verifies transient retries, retry exhaustion, cancellation precedence, generic error responses, and removal of SQL parameters and raw stacks from logs.

Reviews (3): Last reviewed commit: "fix(tools): preserve preflight cancellat..." | Re-trigger Greptile

Comment thread apps/sim/tools/index.ts Outdated
Comment thread apps/sim/tools/index.ts
Comment thread apps/sim/tools/index.ts Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/tools/index.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c93972b. Configure here.

@TheodoreSpeaks
TheodoreSpeaks merged commit 1faac4e into staging Aug 12, 2026
31 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the fix/timeout-query branch August 12, 2026 22:35
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.

1 participant