Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable annotation fixes for consistency #41

Merged
merged 3 commits into from
Apr 1, 2024
Merged

Conversation

tillig
Copy link
Member

@tillig tillig commented Mar 28, 2024

Fixes #40.

Issue #40 indicated that the ITenantIdentificationStrategy.TryIdentifyTenant was allowing for a null return value if the method returned true.

While I think this is a super edge case, technically speaking we do have the concept of a "default tenant" in the system that is indicated by a null tenant ID. Thus, it is technically possible someone may want to say, "I looked, and I intentionally have determined that we should use the default tenant ID, thus I am intentionally setting the return value to null."

I found that we weren't correctly handling all nullable annotations in MultitenantContainer, so that has been updated. I've also added some documentation to explain the potential intentional null; and some unit tests to illustrate more of the notion of intentional identification-as-null.

The other option here would be to make a change to the TryIdentifyTenant method definition such that it's not allowed to return null if the tenant is identified. I think it's possible this is a breaking change given that sort of behavior is currently allowed and we've definitely seen people doing every possible edge case out there, even if it's not the 80% case. If we did that, it may be that we need to have a public/singleton for the default tenant ID such that an intentional identification as the default tenant will result in a non-null tenant ID. Not a huge lift, but not just a nullable annotation change, either.

@tillig tillig requested a review from alistairjevans March 28, 2024 15:41
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.57%. Comparing base (1a7a9eb) to head (9f33d44).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #41   +/-   ##
========================================
  Coverage    93.57%   93.57%           
========================================
  Files            5        5           
  Lines          109      109           
  Branches        28       28           
========================================
  Hits           102      102           
  Misses           3        3           
  Partials         4        4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@alistairjevans alistairjevans left a comment

Choose a reason for hiding this comment

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

🏄

@tillig tillig merged commit bb194cd into develop Apr 1, 2024
6 checks passed
@tillig tillig deleted the feature/nullable-fixes branch April 1, 2024 18:18
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.

ITenantIdentificationStrategy.TryIdentifyTenant nullable annotation incomplete
2 participants