Skip to content

feat(sentry): capture AI cloud weather tool errors#2378

Merged
mikib0 merged 1 commit into
developmentfrom
feat/sentry-ai-weather-tool-errors
May 6, 2026
Merged

feat(sentry): capture AI cloud weather tool errors#2378
mikib0 merged 1 commit into
developmentfrom
feat/sentry-ai-weather-tool-errors

Conversation

@mikib0
Copy link
Copy Markdown
Collaborator

@mikib0 mikib0 commented May 6, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling for weather API calls with improved error messages when requests fail.
    • Strengthened error tracking and diagnostics for weather feature operations to identify and resolve issues more effectively.

…umbs

- Add Sentry breadcrumbs at every tool call state transition
  (input-streaming → input-available → output-available/output-error)
  so the full flow is visible in the breadcrumb trail on any error
- Capture output-available failures as captureException and
  output-error stream failures as captureException, both tagged
  ai_tool=getWeatherForLocation / ai_mode=cloud
- Enrich the API WeatherService error to include HTTP status code and
  the OpenWeatherMap response message (e.g. "city not found") plus the
  queried location, replacing the generic "Weather API request failed"
- Add Sentry captureException to expo weatherService for
  searchLocations, searchLocationsByCoordinates, and getWeatherData
  API failures, each with input context and a weather_operation tag
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c7a43989-41a7-444f-8695-36381fc8ad04

📥 Commits

Reviewing files that changed from the base of the PR and between a4cb13b and de52096.

📒 Files selected for processing (4)
  • apps/expo/features/ai/components/WeatherGenerativeUI.tsx
  • apps/expo/features/ai/lib/tools.ts
  • apps/expo/features/weather/lib/weatherService.ts
  • packages/api/src/services/weatherService.ts

Walkthrough

This PR adds Sentry instrumentation across the weather feature stack, from API error handling through to AI-driven UI components. Error reporting now captures contextual data (location, coordinates, operation types) and state transitions are tracked via breadcrumbs for debugging.

Changes

Sentry Instrumentation for Weather Features

Layer / File(s) Summary
API Error Handling
packages/api/src/services/weatherService.ts
Enhanced error path for non-OK API responses to parse message from response body, fall back to statusText, and include location context in the thrown error.
Weather Service Error Capture
apps/expo/features/weather/lib/weatherService.ts
Three weather API call handlers (searchLocations, searchLocationsByCoordinates, getWeatherData) now create Error objects and report them to Sentry with relevant context (query, coordinates, locationId) and a weather_operation tag before throwing.
AI Tools Integration
apps/expo/features/ai/lib/tools.ts
Added Sentry breadcrumb logging in getWeatherForLocation to record tool invocation with location parameter.
UI Component Instrumentation
apps/expo/features/ai/components/WeatherGenerativeUI.tsx
Added useEffect hook that emits Sentry breadcrumbs for streaming, input-available, and output-available states (including success/error paths) and captures streaming exceptions with context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sentry-ai-weather-tool-errors

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mikib0 mikib0 merged commit 7c859db into development May 6, 2026
9 of 11 checks passed
@mikib0 mikib0 deleted the feat/sentry-ai-weather-tool-errors branch May 6, 2026 20:40
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Coverage Report for API Unit Tests Coverage (./packages/api)

Status Category Percentage Covered / Total
🔵 Lines 72.93% 609 / 835
🔵 Statements 72.93% (🎯 65%) 609 / 835
🔵 Functions 96% 48 / 50
🔵 Branches 88.27% 271 / 307
File CoverageNo changed files found.
Generated in workflow #1066 for commit de52096 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Coverage Report for Expo Unit Tests Coverage (./apps/expo)

Status Category Percentage Covered / Total
🔵 Lines 81.7% 536 / 656
🔵 Statements 81.7% (🎯 75%) 536 / 656
🔵 Functions 92.98% 53 / 57
🔵 Branches 89.73% 201 / 224
File CoverageNo changed files found.
Generated in workflow #1066 for commit de52096 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant