Skip to content

Improve error handling and sanitization in tool execution - #183

Merged
artemo-brd merged 11 commits into
brightdata:mainfrom
artemo-brd:fix/sanitize-tool-error-handling
Sep 11, 2026
Merged

artemo-brd merged 11 commits into
brightdata:mainfrom
artemo-brd:fix/sanitize-tool-error-handling

Conversation

@artemo-brd

Copy link
Copy Markdown
Collaborator

Summary

Improve handling errors across tool executions, particularly for scrape_batch. Failed entries and tool errors now return clean, sanitized messages, improving consistency and robustness of tool output.

Also includes:

  • A minor fix to a broken string concatenation in the usage-limit error message.
  • Additional offline regression test coverage for error handling paths.

- scrape_batch now returns a sanitized per-URL error message instead of
  serializing the raw rejection reason, matching the existing pattern in
  search_engine_batch.
- Added a centralized error-sanitization boundary in tool_fn so no tool can
  propagate an unsanitized exception object out of a tool call.
- Added a defense-in-depth Axios interceptor that redacts sensitive request
  headers on errors.
- Extracted the sanitization helpers into a standalone, unit-tested
  error_sanitizer.js module.
- Removed an internal stack trace from the ARIA snapshot filter's error
  output.
- Added regression and unit tests covering a wide range of failure modes
  (HTTP errors, timeouts, DNS/TLS/connection failures, non-Error
  rejections, and malicious toJSON()).

Bump version to 2.11.2.
…file

- scrape_batch and search_engine_batch now route failures through the
  shared sanitize_error() instead of e.message/String(e) locally.
- scrape_batch keeps its original Promise.allSettled response shape
  ({status, value|reason}); a rejected item's reason is now always a
  sanitized string.
- Add an overridable base URL constant so requests can be pointed at a
  local stub server for tests.
- Add a fully offline, deterministic test using a local HTTP stub covering
  a partial batch (one success, one failure).
- Sync package-lock.json version to 2.11.2.
@artemo-brd
artemo-brd merged commit 0cddd56 into brightdata:main Sep 11, 2026
1 check passed
@artemo-brd
artemo-brd deleted the fix/sanitize-tool-error-handling branch September 11, 2026 12:53
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