Skip to content

Conversation

@amolmjoshi93
Copy link
Contributor

@amolmjoshi93 amolmjoshi93 commented Jan 27, 2026

Closes #2048

Prevents ActionView::MissingTemplate errors when requests are made to .well-known/assetlinks.json by excluding these paths from the catch-all route and adding proper format handling in HomeController.

Sentry: https://saeloun-inc.sentry.io/issues/MIRU-WEB-7

Summary by CodeRabbit

  • Bug Fixes

    • Public index now returns 404 for JSON requests instead of rendering HTML.
    • Catch-all routing updated to exclude well-known paths to prevent unintended matches.
  • Tests

    • Added request specs verifying JSON 404 behavior and well-known path handling.

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

Fixes MIRU-WEB-7

Prevents ActionView::MissingTemplate errors when requests are made to
.well-known/assetlinks.json by excluding these paths from the catch-all
route and adding proper format handling in HomeController.

Sentry: https://saeloun-inc.sentry.io/issues/MIRU-WEB-7
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Catch-all routes now exclude paths starting with /.well-known, and HomeController#index responds to HTML while returning 404 for JSON requests; admin redirect behavior is unchanged.

Changes

Cohort / File(s) Summary
Route Guard Exclusion
config/routes.rb
Added constraint to the catch-all match "*path" so requests whose path starts with /.well-known are not routed to HomeController#index.
Content Negotiation
app/controllers/home_controller.rb
index action updated to respond_to HTML (render) and JSON (head :not_found); admin redirect to admin_root_path remains unchanged.
Tests / Specs
spec/requests/home/index_spec.rb
Added request specs asserting JSON requests to root return 404 and that /.well-known/assetlinks.json returns 404.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Router
  participant HomeController
  participant AdminApp

  Client->>Router: GET /.well-known/assetlinks.json
  alt Before change (catch-all matched)
    Router->>HomeController: route to index (format=json)
    HomeController->>HomeController: render (no json template)
    HomeController-->>Client: 500 ActionView::MissingTemplate (error)
  else After change (excluded + controller handling)
    Router--xClient: 404 Not Found
    note right of Router: OR
    Router->>HomeController: route to index (if matched)
    HomeController->>HomeController: respond_to -> head :not_found for json
    HomeController-->>Client: 404 Not Found
  end

  Client->>Router: GET / (html)
  Router->>HomeController: route to index
  HomeController->>HomeController: if admin -> redirect to AdminApp
  HomeController-->>Client: HTML response or redirect
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through routes both wide and small,
Found .well-known doors that tangled all.
I nudged the guard, taught JSON to say "no",
Now stray requests quietly don't show.
Hooray — no missing templates in the meadow! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately describes the main change: excluding .well-known paths from the catch-all route, which is the primary solution to prevent ActionView::MissingTemplate errors.
Linked Issues check ✅ Passed The PR implements both key objectives from issue #2048: excludes .well-known paths from catch-all route [#2048] and adds explicit format handling in HomeController#index to return 404 for JSON requests [#2048].
Out of Scope Changes check ✅ Passed All changes are in-scope: route constraints for .well-known exclusion, HomeController format handling, and request specs validating the 404 behavior are all directly addressing issue #2048 requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • WEB-7: Entity not found: Issue - Could not find referenced Issue.

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.

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

Labels

None yet

Projects

None yet

2 participants