Skip to content

fix: enhance error tracking and handling for Salesforce API interactions#1875

Open
paustint wants to merge 3 commits into
mainfrom
fix/error-tracker-fixes
Open

fix: enhance error tracking and handling for Salesforce API interactions#1875
paustint wants to merge 3 commits into
mainfrom
fix/error-tracker-fixes

Conversation

@paustint

Copy link
Copy Markdown
Contributor

Improve error handling and tracking. based no errors in our error tracker

Copilot AI review requested due to automatic review settings July 22, 2026 15:46
@paustint
paustint force-pushed the fix/error-tracker-fixes branch from 980d8aa to a458d8b Compare July 22, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves resilience and signal quality for Salesforce API interactions across the UI, shared utilities, and the API server by adding clearer user-facing errors, more targeted retries, and better error-tracker fingerprinting/ignores.

Changes:

  • Improve handling of common Salesforce failure modes (expired query locators, invalid sessions, Bulk API v1 auth failures) and adjust retry behavior for idempotent pagination/network errors.
  • Reduce error-tracker noise and improve fingerprinting by passing real Error instances and ignoring known non-actionable client/runtime errors.
  • Harden export and load flows (Excel cell truncation for .xlsx, CSV batch sizing to avoid Bulk API v1 request-size rejections), with added unit coverage for new batching logic and Bulk API v1 auth refresh.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
libs/ui/src/lib/file-download-modal/RecordDownloadModal.tsx Shows more specific download error messaging (esp. .xlsx limits) and routes error text through getErrorMessage().
libs/ui/src/lib/data-table/SalesforceRecordDataTable.tsx Detects expired Salesforce query locators and guides the user to re-run the query instead of retrying load-more.
libs/shared/ui-utils/src/lib/shared-ui-utils.ts Truncates oversized Excel cell values to ensure .xlsx generation succeeds under Excel’s per-cell limit.
libs/shared/ui-utils/src/lib/shared-ui-data-utils.ts Hardens Tooling composite batching by throwing a clear error on empty/invalid responses.
libs/shared/ui-utils/src/lib/errorTracker.ts Expands ignore lists to reduce known non-actionable error noise.
libs/shared/ui-db/src/lib/ui-db.ts Wraps dexie-observable localStorage writes and adds a reopen-and-retry helper for DatabaseClosedError.
libs/shared/ui-db/src/lib/api-request-history.db.ts Uses the reopen-and-retry helper to make history persistence more robust across Dexie connection closures.
libs/shared/data/src/lib/client-data-data-helper.ts Retries idempotent pagination on network-level failures and improves “empty-body” and network error messaging.
libs/shared/constants/src/lib/shared-constants.ts Adds a constant for Bulk API v1 invalid-session messaging.
libs/salesforce-api/src/lib/callout-adapter.ts Treats Bulk API v1 “InvalidSessionId” (HTTP 400 XML) as an auth failure eligible for refresh-token retry.
libs/salesforce-api/src/lib/tests/callout-adapter.spec.ts Adds unit coverage for Bulk API v1 InvalidSessionId refresh behavior.
libs/features/salesforce-api/src/SalesforceApi.tsx Improves tracker event naming for API history persistence failures.
libs/features/manage-permissions/src/utils/permission-manager-table-utils.tsx Adds optional chaining to avoid crashes when profile fields are missing.
libs/features/manage-permissions/src/usePermissionRecords.tsx Corrects logging/tracking identifiers for clearer attribution.
libs/features/load-records/src/utils/load-records-process.ts Adds size-capped Bulk API CSV batch generation to avoid Salesforce’s per-batch request-size limit.
libs/features/load-records/src/utils/tests/load-records-process.spec.ts Adds unit coverage for size-capped CSV batch generation behavior.
libs/features/load-records/src/components/load-results/LoadRecordsBulkApiResults.tsx Avoids reporting user-abort batch errors to the error tracker while keeping UI behavior intact.
libs/features/automation-control/src/useAutomationControlData.ts Improves error tracker fingerprinting by passing an Error rather than a plain object for fetch failures.
apps/api/src/app/utils/response.handlers.ts Treats “Invalid session id” as an auth/session failure in server error handling logic.

Comment thread libs/shared/ui-utils/src/lib/errorTracker.ts
Copilot AI review requested due to automatic review settings July 22, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 25 out of 25 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

libs/shared/ui-utils/src/lib/errorTracker.ts:26

  • This ignored substring is lowercase, but shouldIgnore() uses a case-sensitive candidate.includes(needle) check. Salesforce errors often surface as INVALID_QUERY_LOCATOR (upper snake case), so this may not actually suppress the intended noise.
  // dexie-observable's unload-time localStorage write for users at storage quota — guarded in ui-db,
  // but old bundles remain in the field.
  'Dexie.Observable/deadnode',
  // Expired/evicted Salesforce query cursor — the user must re-run their query; nothing to fix client-side.
  'invalid query locator',
];

Comment thread libs/shared/ui-db/src/lib/ui-db.ts
paustint added 2 commits July 24, 2026 06:42
Improve error handling and tracking. based no errors in our error tracker
Copilot AI review requested due to automatic review settings July 24, 2026 13:43
@paustint
paustint force-pushed the fix/error-tracker-fixes branch from a458d8b to 58c6c2e Compare July 24, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 25 out of 25 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 24, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 25 out of 25 changed files in this pull request and generated 2 comments.


const SOAP_API_AUTH_ERROR_REGEX = /<faultcode>[a-zA-Z]+:INVALID_SESSION_ID<\/faultcode>/;
// Bulk API v1 reports session-auth failures as HTTP 400 with an XML body instead of a 401
const BULK_XML_AUTH_ERROR_REGEX = /<exceptionCode>InvalidSessionId<\/exceptionCode>/;
const { endpoints, retry, retryDelay, methods, statusCodes } = RETRY_CONFIG;
// Network-level failures (no response at all — connection drop, proxy kill) are retryable for the
// same idempotent GET endpoints as 429/5xx responses; canceled requests are never retried.
const isRetryableNetworkError = !error.response && error.code !== 'ERR_CANCELED';
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.

2 participants