fix: Improve HTTP error handling and fix null dereference in code fix provider#1692
Conversation
Issue #1574 - SuccessHttpHandler unconditionally throws: - Add HttpResponseException class with detailed error information - Include status code, reason phrase, response content, and request URI - Create EnsureSuccessStatusCodeWithContentAsync extension method - Replace EnsureSuccessStatusCode() calls in Http.cs and Downloader.cs - Response content is truncated at 2000 chars to avoid excessive messages Issue #1550 - Null dereference in AsyncModuleCodeFixProvider.AddAsync: - Replace First()! with FirstOrDefault() for expression syntax lookup - Add null checks for return statements without expressions - Add null checks for ArgumentList and inner expression extraction - Gracefully skip malformed return statements instead of throwing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SummaryImproves HTTP error handling with detailed exception messages and adds defensive null checks to the async module code fix provider. Critical IssuesNone found ✅ Suggestions1. Consider adding tests for the new exception typeThe new
2. Minor optimization in HttpResponseExtensions.cs:70The catch block swallows all exceptions when reading response content. While this is acceptable for robustness, consider at least catching specific exceptions like 3. Code fix analyzer improvements look goodThe defensive null checks in
This addresses potential crashes when the code fix encounters edge cases like bare Verdict✅ APPROVE - No critical issues The changes improve error diagnostics significantly by including response content in HTTP exceptions, making debugging much easier. The analyzer fixes add proper null safety for edge cases. |
Summary
HttpResponseExceptionfor detailed HTTP error informationEnsureSuccessStatusCodeWithContentAsyncextension method for better error messagesAsyncModuleCodeFixProviderChanges
HttpResponseException.cs: Exception with status code, reason phrase, and response contentHttpResponseExtensions.cs: Extension method for HTTP response validation with contentHttp.csandDownloader.csto use new extension methodAsyncModuleCodeFixProvider.cs: Added null checks using FirstOrDefault()Fixes #1574, Fixes #1550
Test plan
🤖 Generated with Claude Code