You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "matrei (via GitHub)" <gi...@apache.org> on 2026/10/04 12:09:56 UTC

[PR] Rethrow TenantNotFoundException from the multi-tenant event listener [grails-core]

matrei opened a new pull request, #16509:
URL: https://github.com/apache/grails-core/pull/16509

   ## Description
   
   In discriminator multi-tenancy, GORM's `MultiTenantEventListener` sets the current tenant id on an instance before it is validated, inserted or updated. When there is no current tenant, the tenant resolver throws a `TenantNotFoundException`.
   
   Since #16066, the listener resolves the tenant inside the `try` block that turns a failure to set the property into a `TenantException`. A save without a tenant then fails with a misleading message:
   
   ```
   TenantException: Could not assigned tenant id [null] to property [tenantId], probably due to a type mismatch.
   You should return a type from the tenant resolver that matches the property type of the tenant id!
   ```
   
   It used to throw the `TenantNotFoundException`, and a query without a tenant still does. 7.0.x is not affected.
   
   The listener now rethrows a `TenantNotFoundException` unchanged. A failure to set the tenant id property is still wrapped as before.
   
   This affects the datastores that use GORM's listener, such as MongoDB and the simple datastore. GORM for Hibernate 5 and 7 have their own listener.
   
   ### Tests
   
   - `MultiTenantEventListenerSpec`: a new feature checks that a `TenantNotFoundException` from the tenant resolver is rethrown unwrapped, and that no tenant id is set.
   - `PartitionMultiTenancySpec` (simple datastore): a new feature checks through the public API that saving without a tenant throws `TenantNotFoundException`.
   
   Both new features fail without the change. All multi-tenancy specs of `grails-datamapping-core` and `grails-datamapping-core-test` pass, and so do `checkstyleMain` and `codenarcTest` of `grails-datamapping-core`.


-- 
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] Rethrow TenantNotFoundException from the multi-tenant event listener [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty merged PR #16509:
URL: https://github.com/apache/grails-core/pull/16509


-- 
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] Rethrow TenantNotFoundException from the multi-tenant event listener [grails-core]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16509:
URL: https://github.com/apache/grails-core/pull/16509#issuecomment-5980220111

   ## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/16509?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 59.4056%. Comparing base ([`620d549`](https://app.codecov.io/gh/apache/grails-core/commit/620d549caaf29f053bd2a855583fe8a4d89af74c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`0a657b3`](https://app.codecov.io/gh/apache/grails-core/commit/0a657b30739681d1e5c335c750d3922832b3384e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 30 commits behind head on 8.0.x.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/grails-core/pull/16509/graphs/tree.svg?width=650&height=150&src=pr&token=qJrryhpk7u&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/grails-core/pull/16509?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##                8.0.x     #16509        +/-   ##
   ==================================================
   + Coverage     59.4048%   59.4056%   +0.0007%     
   + Complexity      24859      24857         -2     
   ==================================================
     Files            2171       2171                
     Lines          108237     108239         +2     
     Branches        19744      19744                
   ==================================================
   + Hits            64298      64300         +2     
   + Misses          35001      34999         -2     
   - Partials         8938       8940         +2     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/grails-core/pull/16509?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...re/gorm/multitenancy/MultiTenantEventListener.java](https://app.codecov.io/gh/apache/grails-core/pull/16509?src=pr&el=tree&filepath=grails-datamapping-core%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fdatastore%2Fgorm%2Fmultitenancy%2FMultiTenantEventListener.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLWNvcmUvc3JjL21haW4vZ3Jvb3Z5L29yZy9ncmFpbHMvZGF0YXN0b3JlL2dvcm0vbXVsdGl0ZW5hbmN5L011bHRpVGVuYW50RXZlbnRMaXN0ZW5lci5qYXZh) | `79.6610% <100.0000%> (+0.7136%)` | :arrow_up: |
   
   ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/16509/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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] Rethrow TenantNotFoundException from the multi-tenant event listener [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16509:
URL: https://github.com/apache/grails-core/pull/16509#issuecomment-5980727378

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 0a657b30739681d1e5c335c750d3922832b3384e
   ▶️ Tests:  94492 executed
   ⚪️ Checks: 85/85 completed
   
   ---
   _Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   


-- 
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