Skip to content

7.1.x FIX: Rank URL mapping specificity by literal token count before wildcard captures - #15645

Merged
codeconsole merged 3 commits into
apache:7.1.xfrom
codeconsole:7.1.x-url-mapping-specificity
May 18, 2026
Merged

7.1.x FIX: Rank URL mapping specificity by literal token count before wildcard captures#15645
codeconsole merged 3 commits into
apache:7.1.xfrom
codeconsole:7.1.x-url-mapping-specificity

Conversation

@codeconsole

@codeconsole codeconsole commented May 8, 2026

Copy link
Copy Markdown
Contributor

When wildcard validation is enabled, AbstractGrailsControllerUrlMappings now sorts validated wildcard matches first by literal URL-token count (more literals = more specific) and only then by non-routing capture count. Previously a generic pattern like /$id/$action/$imageId could win over a more specific route such as /list/$stage/$sort because both had the same wildcard-capture status, causing the wrong controller/action to be resolved regardless of declaration order. Adds two WildcardActionValidationSpec cases covering both declaration orders.

#15525
#15542

@jdaugherty

Copy link
Copy Markdown
Contributor

@codeconsole looks like this broke some tests. if you can fix them, I'm happy to follow-up with a review.

The /** catch-all pattern tokenizes to a single bare ** token (not (**))
because configureUrlPattern only rewrites (*)**. That made literalTokenCount
count ** as a literal, ranking /** above /$controller/$action?/$id? and
breaking DoubleWildcardUrlMappingTests.testDoubleWildcardWithMatchingController.

Switch the predicate to !t.contains('*'), which correctly treats any token
holding a wildcard char as non-literal.
@testlens-app

testlens-app Bot commented May 15, 2026

Copy link
Copy Markdown

🚨 TestLens detected 1 failed tests 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Check Project/Task Test Runs
CI / Functional Tests (Java 21, indy=false) :grails-test-examples-scaffolding:integrationTest UserControllerSpec > User list

🏷️ Commit: 3804600
▶️ Tests: 36164 executed
🟡 Checks: 36/37 completed

Test Failure

UserControllerSpec > User list (:grails-test-examples-scaffolding:integrationTest in CI / Functional Tests (Java 21, indy=false))
geb.waiting.WaitTimeoutException: condition did not pass in 10 seconds (failed with exception)
	at geb.waiting.Wait.waitFor(Wait.groovy:128)
	at geb.waiting.DefaultWaitingSupport.doWaitFor(DefaultWaitingSupport.groovy:55)
	at geb.waiting.DefaultWaitingSupport.waitFor(DefaultWaitingSupport.groovy:41)
	at geb.Page.waitFor(Page.groovy:120)
	at com.example.pages.LoginPage.login(LoginPage.groovy:39)
	at com.example.UserControllerSpec.setup(UserControllerSpec.groovy:33)
Caused by: Assertion failed: 

title != pageTitle
|     |  |
|     |  'Please sign in'
|     false
'Please sign in'

	at com.example.pages.LoginPage.login_closure1(LoginPage.groovy:39)
	at com.example.pages.LoginPage.login_closure1(LoginPage.groovy)
	at geb.waiting.Wait.waitFor(Wait.groovy:117)
	... 5 more

Muted Tests

Note

Checks are currently running using the configuration below.

Select tests to mute in this pull request:

🔲 UserControllerSpec > User list

Reuse successful test results:

🔲 ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

🔲 Rerun jobs


Learn more about TestLens at testlens.app.

@codeconsole
codeconsole requested review from jamesfredley, jdaugherty, matrei and sbglasius and removed request for matrei May 15, 2026 16:13
@codeconsole
codeconsole merged commit c607460 into apache:7.1.x May 18, 2026
63 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants