spring-projects / spring-projects/spring-data-commons
Null Handling of Repository Methods not implemented correctly for "Containing" kind of methods
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 838
- Forks
- 730
- PR merge metrics
- No merged PRs in 30d
Description
In the documentation we see that it is possible to manage nullability for the repository methods. Look at section 9.4.7 Null Handling of Repository Methods.

While it works for simple methods like:
User findByEmailAddress(@Nullable EmailAddress emailAdress);
The same approach will cause an error for "Containing" kind of methods:
User findByFirstnameContaining(@Nullable String name)
If I call this method with null name I get this error: "message": "Argument for creating $regex pattern for property 'section' must not be null!"
I think the more appropriate solution would be omitting any null input parameter during query building phase.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the documented section 9.4.7 and reproduce the failure using a repository method such as findByFirstnameContaining with a null argument. Trace the repository query-building path for Containing methods and compare it with the simple nullable method behavior. Done means the intended null handling is implemented and covered by verification for the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100