Skip to content

Route not found error for wildcard routes - #213

Merged
mikebronner merged 2 commits into
mainfrom
fix/209-route-not-found-error-for-wildcard-routes
Jun 18, 2026
Merged

mikebronner merged 2 commits into
mainfrom
fix/209-route-not-found-error-for-wildcard-routes

Conversation

@mikebronner

@mikebronner mikebronner commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements #209 — wildcard route references (e.g. route()->routeIs('players.*'), Route::has('players.competitions.*'), Ziggy patterns) were being flagged with a false-positive "Route not found" ERROR, because a wildcard name never appears verbatim in the route index.

Changes

  • route_not_found_diagnostics (laravel-lsp/src/main.rs) now skips any RouteReferenceData whose name contains *, guarding before the index lookup. The guard sits in the pure function ahead of any I/O, so both the PHP and Blade call sites inherit it and no LSP restart or cache flush is needed.
  • New regression test wildcard_route_names_flag_nothing in laravel-lsp/src/tests/route_diagnostics.rs.

Acceptance Criteria

  • route_not_found_diagnostics skips any RouteReferenceData whose name contains * — no "Route not found" diagnostic is emitted for wildcard patterns
  • Suppression applies identically to both the PHP branch and the Blade branch (both call the same function, no separate fix needed)
  • A new test in laravel-lsp/src/tests/route_diagnostics.rs confirms a route_ref with a wildcard name (players.*, players.competitions.*) produces zero diagnostics against a non-empty index that contains no exact match
  • Existing "Route not found" diagnostics for non-wildcard exact misses (e.g. does.not.exist) continue to fire unchanged — verified by flags_only_unknown_routes still passing
  • No LSP restart or cache flush is required — the guard is applied in the pure function before any I/O

Test Plan

  • cargo test route_diagnostics — all 5 pass (4 existing + 1 new)
  • cargo test — full unit suites green (1875 + 396 passing)
  • cargo clippy — clean
  • cargo fmt — applied

Note: 8 pre-existing failures in tests/integration_tests.rs (env-file / test-project fixture dependencies) are present on the base branch unmodified and are unrelated to this change — verified by re-running them with this PR's edits stashed.

Fixes #209

mikebronner and others added 2 commits June 18, 2026 06:23
…209)

Wildcard patterns like `players.*` reference a *family* of registered
routes (Route::has, routeIs, Ziggy) and never appear verbatim in the
route index, so `route_not_found_diagnostics` emitted a false-positive
"Route not found" ERROR for them.

Guard the pure function to skip any RouteReferenceData whose name
contains `*`, before the index lookup. Both the PHP and Blade call
sites share this function, so the fix covers both with no LSP restart
or cache flush. Adds a regression test asserting wildcard names produce
zero diagnostics against a non-empty index with no exact match.

Fixes #209

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mikebronner
mikebronner marked this pull request as ready for review June 18, 2026 13:27

@mr-sherlock-holmes mr-sherlock-holmes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved

Review Summary

  • Fix suppresses the false-positive "Route not found" diagnostic for wildcard route patterns (players.*, players.competitions.*) via a single if r.name.contains('*') { continue; } guard inside route_not_found_diagnostics (laravel-lsp/src/main.rs:15824).
  • Every acceptance criterion is met:
    • AC #1 — guard skips any RouteReferenceData whose name contains * before the index lookup. ✅
    • AC #2 — the guard lives in the one shared pure function; both the PHP call site (main.rs:16804) and the Blade call site (main.rs:17169, explicitly "same check as the PHP branch above") inherit it with no separate fix. ✅
    • AC #3 — wildcard_route_names_flag_nothing (tests/route_diagnostics.rs:70-83) asserts zero diagnostics against a non-empty index (players.competitions.index, players.competitions.create) with no exact match for the wildcard names. It's a real test: remove the guard and both refs fall through to index.get(...).is_none(), producing 2 diagnostics and failing the assert. ✅
    • AC #4 — the existing flags_only_unknown_routes test is untouched and still flags does.not.exist (no *) exactly once; non-wildcard exact misses fire unchanged. ✅
    • AC #5 — the guard is in the pure function operating on the already-read in-memory index, before any I/O — no LSP restart or cache flush needed. ✅
  • Tests verified: CI fully green (LSP test/fmt/clippy, extension wasm/fmt/clippy, analyze). No correctness, security, or test-honesty defects surfaced.
  • Tight, well-commented, minimal diff that matches the repo's conventions. Nicely done.

📋 Non-blocking follow-ups

  • None.

Ready for @mikebronner to merge.

@mikebronner
mikebronner merged commit 71298bc into main Jun 18, 2026
5 checks passed
@mikebronner
mikebronner deleted the fix/209-route-not-found-error-for-wildcard-routes branch June 18, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Route not found error for wildcard routes

1 participant