You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "codeconsole (via GitHub)" <gi...@apache.org> on 2026/03/23 05:04:54 UTC
[PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
codeconsole opened a new pull request, #15525:
URL: https://github.com/apache/grails-core/pull/15525
Validates namespace, controller and action. If validation fails, triggers next mapping.
```groovy
"/$namespace/$controller/$action?/$id?(.$format)?" {}
"/$controller/$action?/$id?(.$format)?"{}
"/$username"(controller: 'profile', action: 'show'
```
Without validation, you have to a do something messy like this:
```
"/$username"(ontroller: 'profile', action: 'show') {
constraints {
username(validator: { val -> !(val in reserved) })
}
}
```
I can't think why you would want to disable this feature, but it can be disabled via:
```yaml
grails:
web:
url:
mapping:
validateWildcards: false
```
Does not affect performance:
1. Calls info.configure(webRequest) for each match — sets params on the web request
2. Does a ConcurrentHashMap.get() for the ControllerKey lookup
3. Now additionally: info.hasWildcardCaptures() (three instanceof checks) when the lookup misses
Steps 1 and 2 were already happening before this change. The only new cost is step 3, which is negligible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4114756853
## 🔎 No tests executed 🔎
🏷️ Commit: 7feb6b5a1d186e857c093896f5efe978b897c28c
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4108914540
## 🔎 No tests executed 🔎
🏷️ Commit: 575420b29daa13d6e0030b43e63577a644dd8e1f
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4148845955
@codeconsole There is an existing config setting with the config key:
```yml
grails:
urlmapping:
cache:
maxsize: 1000
```
Should we use that namespace instead for validateWildcards?
```yml
grails:
urlmapping:
validateWildcards: false
cache:
maxsize: 1000
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4147734622
## 🔎 No tests executed 🔎
🏷️ Commit: c9c42a9e926a0e544b1cb5b0ce9398192a84fd21
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4108110997
## 🚨 TestLens detected 2 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 / Build Grails-Core \(ubuntu-latest, 25\)](https://github.com/apache/grails-core/actions/runs/23422318999/job/68129948641?pr=15525) | :grails-test-suite-web:test | DoubleWildcardUrlMappingTests > testDoubleWildcardInParam | ❌ |
| [CI / Build Grails-Core \(ubuntu-latest, 25\)](https://github.com/apache/grails-core/actions/runs/23422318999/job/68129948641?pr=15525) | :grails-test-suite-web:test | DoubleWildcardUrlMappingTests > testDoubleWildcardWithMatchingController | ❌ |
🏷️ Commit: 3e9f368536404d0541280a51384323a0af5a766d
▶️ Tests: 27977 executed
🟡 Checks: 18/32 completed
### Test Failures
<details>
<summary><strong>DoubleWildcardUrlMappingTests > testDoubleWildcardInParam</strong> (:grails-test-suite-web:test in <a href="https://github.com/apache/grails-core/actions/runs/23422318999/job/68129948641?pr=15525">CI / Build Grails-Core (ubuntu-latest, 25)</a>)</summary>
```
Condition not satisfied:
"doc/" == c.params.path
| | | |
| | | null
| | [d:1, controller:doubleWildcard, action:otherAction]
| <org.grails.web.mapping.DoubleWildCardController@76a13b12 grails_artefact_gsp_TagLibraryInvoker__developmentMode=false grails_artefact_gsp_TagLibraryInvoker__tagLibraryLookup=null grails_web_api_WebAttributes__grailsApplication=null grails_artefact_Controller__mimeTypesSupport=org.grails.plugins.web.api.MimeTypesApiSupport@514f2b5c grails_web_api_ServletAttributes__applicationContext=null grails_web_api_ServletAttributes__servletContext=null grails_artefact_controller_support_RequestForwarder__linkGenerator=null grails_artefact_controller_support_RequestForwarder__urlConverter=null grails_artefact_controller_support_ResponseRedirector__linkGenerator=null grails_artefact_controller_support_ResponseRedirector__redirectListeners=null grails_artefact_controller_support_ResponseRedirector__requestDataValueProcessor=null grails_artefact_controller_support_ResponseRedirector__useJsessionId=false grails_artefact_controller_support_ResponseRenderer__actionResultTransformers=[] gr
ails_artefact_controller_support_ResponseRenderer__grailsLayoutSelector=null grails_artefact_controller_support_ResponseRenderer__grailsRenderViewMutator=null grails_artefact_controller_support_ResponseRenderer__mimeUtility=null grails_artefact_controller_support_ResponseRenderer__pluginManager=null grails_artefact_controller_RestResponder__PROPERTY_RESPONSE_FORMATS=responseFormats grails_artefact_controller_RestResponder__proxyHandler=null grails_artefact_controller_RestResponder__rendererRegistry=null>
false
at org.grails.web.mapping.DoubleWildcardUrlMappingTests.testDoubleWildcardInParam(DoubleWildcardUrlMappingTests.groovy:80)
```
|expected|actual|
|---|---|
|<s>null</s>|<b>doc/</b>|
</details>
<details>
<summary><strong>DoubleWildcardUrlMappingTests > testDoubleWildcardWithMatchingController</strong> (:grails-test-suite-web:test in <a href="https://github.com/apache/grails-core/actions/runs/23422318999/job/68129948641?pr=15525">CI / Build Grails-Core (ubuntu-latest, 25)</a>)</summary>
```
Condition not satisfied:
'someOther' == info.getControllerName()
| | |
| /** doubleWildcard
false
11 differences (21% similarity)
(s)o(m--)e(Othe--)r(-)
(d)o(ubl)e(Wildca)r(d)
at org.grails.web.mapping.DoubleWildcardUrlMappingTests.testDoubleWildcardWithMatchingController(DoubleWildcardUrlMappingTests.groovy:49)
```
|expected|actual|
|---|---|
|<s>doubleWildcard</s>|<b>someOther</b>|
</details>
### Muted Tests
> [!NOTE]
> Checks are currently running using the configuration below.
Select tests to mute in this pull request:
🔲 DoubleWildcardUrlMappingTests > testDoubleWildcardInParam <!-- uniqueId=[engine:spock]/[spec:org.grails.web.mapping.DoubleWildcardUrlMappingTests]/[feature:$spock_feature_0_1] -->
🔲 DoubleWildcardUrlMappingTests > testDoubleWildcardWithMatchingController <!-- uniqueId=[engine:spock]/[spec:org.grails.web.mapping.DoubleWildcardUrlMappingTests]/[feature:$spock_feature_0_0] -->
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](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole merged PR #15525:
URL: https://github.com/apache/grails-core/pull/15525
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4146615413
## 🔎 No tests executed 🔎
🏷️ Commit: bbc7d2205147f7bacd031f04875df47adc9cbbcb
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "sbglasius (via GitHub)" <gi...@apache.org>.
sbglasius commented on code in PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#discussion_r2981923587
##########
grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/AbstractGrailsControllerUrlMappings.groovy:
##########
@@ -45,16 +47,20 @@ import org.grails.web.servlet.mvc.GrailsWebRequest
* @since 3.0
*/
@CompileStatic
+@Slf4j
abstract class AbstractGrailsControllerUrlMappings implements UrlMappings {
UrlMappings urlMappingsHolderDelegate
UrlConverter urlConverter
+ boolean validateWildcardMappings
ConcurrentHashMap<ControllerKey, GrailsControllerClass> mappingsToGrailsControllerMap = new ConcurrentHashMap<>()
ConcurrentHashMap<ControllerKey, GrailsControllerClass> deferredMappings = new ConcurrentHashMap<>()
AbstractGrailsControllerUrlMappings(GrailsApplication grailsApplication, UrlMappings urlMappingsHolderDelegate, UrlConverter urlConverter = null) {
this.urlMappingsHolderDelegate = urlMappingsHolderDelegate
this.urlConverter = urlConverter
+ this.validateWildcardMappings = grailsApplication?.config?.getProperty(
+ Settings.WEB_URL_MAPPING_VALIDATE_WILDCARDS, Boolean, true) ?: true
def controllerArtefacts = grailsApplication.getArtefacts(ControllerArtefactHandler.TYPE)
Review Comment:
Since right here `grailsApplication` is not safe referenced.
##########
grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/AbstractGrailsControllerUrlMappings.groovy:
##########
@@ -45,16 +47,20 @@ import org.grails.web.servlet.mvc.GrailsWebRequest
* @since 3.0
*/
@CompileStatic
+@Slf4j
abstract class AbstractGrailsControllerUrlMappings implements UrlMappings {
UrlMappings urlMappingsHolderDelegate
UrlConverter urlConverter
+ boolean validateWildcardMappings
ConcurrentHashMap<ControllerKey, GrailsControllerClass> mappingsToGrailsControllerMap = new ConcurrentHashMap<>()
ConcurrentHashMap<ControllerKey, GrailsControllerClass> deferredMappings = new ConcurrentHashMap<>()
AbstractGrailsControllerUrlMappings(GrailsApplication grailsApplication, UrlMappings urlMappingsHolderDelegate, UrlConverter urlConverter = null) {
this.urlMappingsHolderDelegate = urlMappingsHolderDelegate
this.urlConverter = urlConverter
+ this.validateWildcardMappings = grailsApplication?.config?.getProperty(
Review Comment:
Why would `grailsApplication` be `null`? or `config` for that matter? Except perhaps when testing?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4131495339
## 🔎 No tests executed 🔎
🏷️ Commit: cad7b9d1ca80754d8379eeaeb7d45a6e2937c82c
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4146735312
## 🔎 No tests executed 🔎
🏷️ Commit: dd9ca3c3be0879b411ae9e22f458053bc6371739
▶️ Tests: 0 executed
🟡 Checks: 0/5 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4148538728
I am doing some final testing and want to do 1 more doc update before merging
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4149144073
## 🔎 No tests executed 🔎
🏷️ Commit: 04904da5285399b2a56593ff5f84b0589cda34ca
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4166582266
> @codeconsole There is an existing config setting with the config key:
>
> ```yaml
> grails:
> urlmapping:
> cache:
> maxsize: 1000
> ```
>
> Should we use that namespace instead for validateWildcards?
>
> ```yaml
> grails:
> urlmapping:
> validateWildcards: false
> cache:
> maxsize: 1000
> ```
yeah, I will create another PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4146354096
## 🔎 No tests executed 🔎
🏷️ Commit: 42817dfd4a229f9d8566571cab7827e57e49b010
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4148841119
## 🔎 No tests executed 🔎
🏷️ Commit: 8d32f13661d8187d2c2f3f6e207979753127fb7b
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add default validation for $namespace, $controller, and $action url mapping variables [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15525:
URL: https://github.com/apache/grails-core/pull/15525#issuecomment-4148599035
## 🔎 No tests executed 🔎
🏷️ Commit: dda74dca147e1c2c8bb0348f6501afc0ba8be669
▶️ Tests: 0 executed
🟡 Checks: 0/30 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org