Skip to content

fix: guard against null error body in ErrorResponseHandlerV2#10698

Open
AshwinBhatkal wants to merge 2 commits intomainfrom
fix/error-response-handler-null-4284-4286
Open

fix: guard against null error body in ErrorResponseHandlerV2#10698
AshwinBhatkal wants to merge 2 commits intomainfrom
fix/error-response-handler-null-4284-4286

Conversation

@AshwinBhatkal
Copy link
Contributor

Pull Request


📄 Summary

ErrorResponseHandlerV2 crashed when response.data.error was null or undefined (e.g. on a timeout or auth error with a non-standard server response body), causing a secondary TypeError on top of the original API error.

Issues closed by this PR

Closes https://github.com/SigNoz/engineering-pod/issues/4284
Closes https://github.com/SigNoz/engineering-pod/issues/4286


✅ Change Type

  • 🐛 Bug fix

🐛 Bug Context

Root Cause

response.data.error.code / .message / .url / .errors were accessed without any null guard. When the server returns a response without the expected error envelope (e.g. a proxy timeout or a plain auth rejection), response.data.error is null/undefined, causing a crash before the APIError can be thrown.

Fix Strategy

Extract response.data?.error into a variable and use optional chaining with fallbacks for each field, so a well-formed APIError is always thrown regardless of response body shape.


🧪 Testing Strategy

  • Tests added/updated: N/A
  • Manual verification: Dashboard save with a timeout or auth error surfaces a proper error message instead of crashing
  • Edge cases covered: null response body, missing error field, partial error objects

⚠️ Risk & Impact Assessment

  • Blast radius: Only affects ErrorResponseHandlerV2 — all API calls using this handler
  • Potential regressions: None — fallback values match what was previously assumed to always be present
  • Rollback plan: Revert the 5-line change

📝 Changelog

Field Value
Deployment Type Cloud / OSS / Enterprise
Change Type Bug Fix
Description Fixed crash in API error handler when server response body is missing the error envelope

📋 Checklist

  • Tests added or explicitly not required
  • Manually tested
  • Breaking changes documented
  • Backward compatibility considered

@AshwinBhatkal AshwinBhatkal requested a review from a team as a code owner March 24, 2026 14:43
@github-actions github-actions bot added the bug Something isn't working label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant