Skip to content

feat: collect API request/response data in error reporter#201

Open
kfirstri wants to merge 3 commits intomainfrom
claude/enhance-error-reporter-mu1ZQ
Open

feat: collect API request/response data in error reporter#201
kfirstri wants to merge 3 commits intomainfrom
claude/enhance-error-reporter-mu1ZQ

Conversation

@kfirstri
Copy link
Contributor

@kfirstri kfirstri commented Feb 7, 2026

Note

Description

This PR improves API error telemetry by automatically capturing request and response details when ApiError is thrown. The error reporter now extracts the HTTP method, URL, status code, and response body directly from ApiError instances, eliminating the need for manual context setting. This provides richer debugging information for API failures without requiring changes to existing error-throwing code.

Related Issue

Fixes #185

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Extended ApiError class to store request metadata (requestUrl, requestMethod) and responseBody
  • Updated ApiError.fromHttpError() to extract and store request/response data from HTTP errors
  • Modified ErrorReporter.buildProperties() to automatically extract API data from ApiError instances
  • Removed unused manual ErrorContext.api field in favor of automatic extraction
  • Updated API error response schema to handle nullable fields (details, traceback, extra_data)
  • Added comprehensive test coverage for new ApiError properties and extraction logic (77 new test lines)

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (bun test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated CLAUDE.md if I made architectural changes

Additional Notes

This change is backwards-compatible and improves observability for API errors without requiring any changes to existing error handling code. The telemetry now automatically includes api_request_url, api_request_method, api_status_code, and api_response_body properties when an ApiError is captured.

Documentation Update: The CLAUDE.md "What's Captured" section should be updated to reflect the new API error fields that are automatically captured from ApiError instances.


🤖 Generated by Claude | 2026-02-07 23:40 UTC

When an ApiError is thrown, the error reporter now automatically
extracts request URL, method, status code, and response body from
the error and includes them in telemetry. This removes the unused
manual ErrorContext.api field in favor of auto-extraction from
ApiError instances in buildProperties.

https://claude.ai/code/session_01WsgRcUXSBY5v1TppPoDdwZ
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.28-pr.201.a10748c

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.28-pr.201.a10748c"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.28-pr.201.a10748c"
  }
}

Preview published to npm registry — try new features instantly!

@claude
Copy link

claude bot commented Feb 7, 2026

Code Review

I found one issue that should be addressed:

Missing CLAUDE.md Documentation Update

File: CLAUDE.md (lines 638-646)
Issue: The "What's Captured" section should be updated to document the new API telemetry fields.

This PR adds automatic extraction of API request/response data from ApiError instances, introducing these new telemetry properties:

  • api_request_url - The API endpoint URL
  • api_request_method - HTTP method (GET, POST, PUT, etc.)
  • api_status_code - HTTP status code
  • api_response_body - The response body from the API

Why this matters:

  • This is an architectural change in how API errors are captured (from manual ErrorContext.api to automatic extraction)
  • CLAUDE.md Important Rule #10 states: "Keep AGENTS.md updated - Update this file when architecture changes"
  • The PR checklist item "I have updated AGENTS.md if I made architectural changes" is unchecked

Suggested fix:
Add this to the "What's Captured" section:

- API error details (automatically extracted from ApiError instances):
  - Request URL and HTTP method
  - Response status code
  - Response body

Summary: 1 issue found related to CLAUDE.md adherence. No bugs detected in the implementation.

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.

Post hog improvements

2 participants