Skip to content

fix: forest returns 404 for all invalid api paths#6327

Merged
LesnyRumcajs merged 8 commits intomainfrom
shashank/fix-invalid-path-error-code
Dec 11, 2025
Merged

fix: forest returns 404 for all invalid api paths#6327
LesnyRumcajs merged 8 commits intomainfrom
shashank/fix-invalid-path-error-code

Conversation

@sudo-shashank
Copy link
Contributor

@sudo-shashank sudo-shashank commented Dec 10, 2025

Summary of changes

Changes introduced in this pull request:

  • Instead of defaulting to version v1, return 404 error code for all invalid paths.

Reference issue to close (if applicable)

Closes #6188

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Summary by CodeRabbit

  • Bug Fixes

    • Invalid API/RPC paths now return proper 404 responses, improving error handling and API consistency.
  • Documentation

    • Changelog updated to document the API path validation fix.
  • Tests

    • Added a test to verify invalid RPC paths return 404.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Walkthrough

Return HTTP 404 for invalid RPC URIs instead of falling back to v1; change ApiPaths parsing to strip the "/rpc/" prefix before parsing; add a changelog entry and a CI test asserting 404 for invalid RPC paths.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added changelog entry documenting fix for #6327 (Forest returns 404 for invalid API paths).
RPC Request Handling
src/rpc/mod.rs
On failed ApiPaths::from_uri(req.uri()), return HTTP 404 Not Found immediately instead of defaulting to ApiPaths::V1.
Path Parsing Logic
src/rpc/reflect/mod.rs
ApiPaths::from_uri now strips the leading "/rpc/" prefix and parses the remainder (replacing prior last-segment extraction).
Integration Test Script
scripts/tests/calibnet_other_check.sh
Added assertion that POST to an invalid RPC path (e.g., /rpc/v3) returns HTTP 404.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect src/rpc/mod.rs to ensure early 404 doesn’t bypass middleware, logging, or metrics and that valid paths remain unchanged.
  • Verify src/rpc/reflect/mod.rs handles edge cases (trailing slash, empty path, unusual segments) and still recognizes all valid variants.
  • Check the new test (scripts/tests/calibnet_other_check.sh) for flakiness in CI.

Possibly related PRs

Suggested reviewers

  • hanabi1224
  • LesnyRumcajs
  • akaladarshi

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: forest returns 404 for all invalid api paths' clearly and concisely summarizes the main change: ensuring invalid API paths return 404 instead of falling back to v1.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #6188: ApiPaths::from_uri now properly parses paths, src/rpc/mod.rs returns 404 for invalid paths instead of defaulting to v1, and test coverage validates the 404 response.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing invalid API path handling: path parsing logic, 404 response behavior, test validation, and changelog documentation with no unrelated modifications.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch shashank/fix-invalid-path-error-code

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4987fb4 and 0010702.

📒 Files selected for processing (1)
  • scripts/tests/calibnet_other_check.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/tests/calibnet_other_check.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Build MacOS
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build Ubuntu
  • GitHub Check: tests-release
  • GitHub Check: Check
  • GitHub Check: tests
  • GitHub Check: All lint checks
  • GitHub Check: Coverage

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

@sudo-shashank sudo-shashank changed the title fix: return 404 for invalid api paths fix: forest returns 404 for all invalid api paths Dec 10, 2025
@sudo-shashank sudo-shashank marked this pull request as ready for review December 11, 2025 08:48
@sudo-shashank sudo-shashank requested a review from a team as a code owner December 11, 2025 08:48
@sudo-shashank sudo-shashank requested review from akaladarshi and hanabi1224 and removed request for a team December 11, 2025 08:48
Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bugfix should have associated tests.

@LesnyRumcajs LesnyRumcajs added the RPC requires calibnet RPC checks to run on CI label Dec 11, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e920cf3 and 4987fb4.

📒 Files selected for processing (1)
  • scripts/tests/calibnet_other_check.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build MacOS
  • GitHub Check: Build Ubuntu
  • GitHub Check: tests
  • GitHub Check: Coverage
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: All lint checks
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests-release

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LesnyRumcajs LesnyRumcajs added this pull request to the merge queue Dec 11, 2025
Merged via the queue into main with commit 3b2c7a3 Dec 11, 2025
75 of 79 checks passed
@LesnyRumcajs LesnyRumcajs deleted the shashank/fix-invalid-path-error-code branch December 11, 2025 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forest doesn't return 404 on invalid paths

2 participants