Fix crash when HTTPX::ErrorResponse is returned in get_form_body_for_file#2532
Fix crash when HTTPX::ErrorResponse is returned in get_form_body_for_file#2532
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughChecks HTTPX responses in get_form_body_for_file for HTTP URLs and raises ReactOnRailsPro::Error with the underlying HTTPX error instead of accessing response.body on error responses; adds specs and a changelog entry documenting the behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ReviewThe fix itself is minimal and correct — adding the 1. Error type inconsistency (blocking consideration)
2. Test stubs
|
Review: Fix crash when HTTPX::ErrorResponse is returned in get_form_body_for_fileThe fix is correct and minimal — checking for Implementation The two-line change in Test quality The new tests cover the three important cases (local path, HTTP success, HTTP error). However, the error-response test has a fragility worth noting — see inline comment. Missing case The fix correctly handles network-level errors ( |
Greptile SummaryThis PR fixes a crash in Key changes:
Note on error handling: The raw HTTPX error is raised directly rather than being wrapped in Confidence Score: 4/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["get_form_body_for_file(path)"] --> B{"http_url?(path)"}
B -- No --> C["return Pathname.new(path)"]
B -- Yes --> D{"Rails.env.development?"}
D -- No --> E["raise ReactOnRailsPro::Error"]
D -- Yes --> F["response = HTTPX.get(path)"]
F --> G{"response.is_a?(HTTPX::ErrorResponse)"}
G -- Yes --> H["raise response.error<br/>(raw HTTPX error)"]
G -- No --> I["return response.body"]
Last reviewed commit: 546b26e |
|
Addressed all review comments in commit 146d442:
Resolved all current review threads. |
Review SummaryThe fix is correct and well-targeted. Minor suggestionThe So Cleaner alternatives: Option A — rely on the shared interface: error = response.error
raise ReactOnRailsPro::Error, "Failed to fetch dev-server asset from #{path}: #{error}" if errorOption B — explicit type check (most self-documenting): if response.is_a?(HTTPX::ErrorResponse)
raise ReactOnRailsPro::Error, "Failed to fetch dev-server asset from #{path}: #{response.error}"
endIf there is a forward-compatibility reason (e.g. supporting an older HTTPX version where |
|
Code review summary: The fix is correct and well-targeted. Two inline comments were posted covering: (1) suggesting is_a?(HTTPX::ErrorResponse) over the respond_to?(:error) duck-typing guard for clarity, and (2) noting that the instance_double stub with error: nil on HTTPX::Response implies that class already has an error method, which makes the respond_to? guard always-true for real HTTPX objects. The three regression tests cover all code paths cleanly. Overall: behavioral fix is correct and PR is well-scoped; the is_a? suggestion is style-level only. |
ReviewThis is a clean, targeted fix. The change correctly addresses the crash by inspecting What's good:
One minor suggestion (non-blocking): The raised error = response.error
if error
begin
raise error
rescue StandardError
raise ReactOnRailsPro::Error, "Failed to fetch dev-server asset from #{path}: #{error}"
end
endThis is purely optional — the current approach is already a solid improvement over the crash, and the message text is sufficient for manual debugging. Overall, LGTM. The fix is correct and well-tested. |
|
Checked against current |
* origin/master: Fix private_output_path not configured on fresh Shakapacker installs (#2289) Bump the npm-security group across 1 directory with 3 updates (#2387) docs: use https links (#2518) Consolidate changelog to keep only rc6 prerelease (#2533) Fix CSS module class name divergence with rspack SSR (#2489) Bump version to 16.4.0.rc.6 Add BugBot license scanning config (#2515) Fix buildVM promise cleanup ordering (#2483) (#2484) # Conflicts: # CHANGELOG.md
ReviewThe fix is correct and minimal. The approach of checking Two minor observations on the tests: 1. Error test only asserts on the error message, not the path context The error message template is 2. Success-path test stubs
Neither of these is a blocker. The core fix is solid and the changelog entry is well-placed. LGTM. |
|
Postmortem on why this tiny PR took too many cycles. What actually needed fixing:
What burned the extra cycles:
A few numbers from this PR:
How to get through these faster next time:
Net: this was mostly review-process churn, not code complexity. For small PRs, the process should be one AI pass, one batched author response, then a human merge decision. |
Review Cycle RetrospectiveThis PR took 11 commits and 2 days to merge a 44-line bug fix. Here's what happened and how we can do better. Timeline
Root Causes1. Bot reviewer pile-on with contradictory advice. 2. Factually wrong bot feedback caused wasted cycles. 3. Infinite nitpick escalation. The pattern was: fix error wrapping → "now chain the cause" → "now add a comment" → "now use 4. No human reviewer. The author was also the only person addressing feedback. The bots kept generating work with no human to say "this is fine, ship it." Recommendations
|
…file (#2532) ## Summary - handle HTTPX::ErrorResponse in get_form_body_for_file before accessing response.body - raise a consistent ReactOnRailsPro::Error (with path context) when dev-server fetch fails - add regression tests for local file paths, HTTP success responses, and HTTP error responses Closes #2521 ## Test Plan - bundle exec rubocop react_on_rails_pro/lib/react_on_rails_pro/request.rb react_on_rails_pro/spec/react_on_rails_pro/request_spec.rb - cd react_on_rails_pro && BUNDLE_GEMFILE=Gemfile bundle exec rspec spec/react_on_rails_pro/request_spec.rb <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved error handling when fetching development assets from HTTP sources; failures now raise descriptive errors that include the asset path and underlying HTTP error details instead of returning incomplete responses. * **Tests** * Added regression tests covering local file handling, successful HTTP fetches, and HTTP error scenarios to prevent regressions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…upport * origin/master: (38 commits) fix: use env-var-driven ports in Procfile templates to support multiple worktrees (#2539) Fix prettier formatting in auto-bundling doc Docs: Clarify .client/.server suffixes vs use client RSC directive (#2406) Warn against using .server/.client variants with RSC features Docs: move internal-only docs out of published docs trees (#2414) Fix crash when HTTPX::ErrorResponse is returned in get_form_body_for_file (#2532) Skip flaky external URLs in lychee checks (#2547) Update mise docs: prefer shell-level shims over conductor-exec (#2537) Document compression middleware compatibility with streaming SSR (#2544) Fix duplicate node-renderer message reporting in render failures (#2531) Fix private_output_path not configured on fresh Shakapacker installs (#2289) Bump the npm-security group across 1 directory with 3 updates (#2387) docs: use https links (#2518) Consolidate changelog to keep only rc6 prerelease (#2533) Fix CSS module class name divergence with rspack SSR (#2489) Bump version to 16.4.0.rc.6 Add BugBot license scanning config (#2515) Fix buildVM promise cleanup ordering (#2483) (#2484) Fix streaming SSR hangs and silent error absorption in RSC payload injection (#2407) Ensure lefthook uses mise tools in non-interactive shells (#2512) ... # Conflicts: # CHANGELOG.md
Summary
Closes #2521
Test Plan
Summary by CodeRabbit
Bug Fixes
Tests