Preserve nullable values in UseMapOf prose-map conversions - #1204
Open
martinfrancois wants to merge 1 commit into
Open
Preserve nullable values in UseMapOf prose-map conversions#1204martinfrancois wants to merge 1 commit into
UseMapOf prose-map conversions#1204martinfrancois wants to merge 1 commit into
Conversation
4 tasks
martinfrancois
force-pushed
the
agent/repro-use-map-of-nullable-value
branch
2 times, most recently
from
August 16, 2026 01:37
4dc66aa to
fba4ead
Compare
martinfrancois
force-pushed
the
agent/repro-use-map-of-nullable-value
branch
from
August 16, 2026 02:53
fba4ead to
0e7b899
Compare
martinfrancois
marked this pull request as ready for review
August 17, 2026 08:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggested review order: 2 of 52 (Score: 9)
Review first: openrewrite/rewrite#8508
What's changed?
Restricts staged
HashMapconversion to entries whose keys and values are proven non-null. Unknown reference expressions remain unchanged, while values whose non-nullness follows from their expression shape remain eligible.What's your motivation?
Recipe:
org.openrewrite.java.migrate.util.UseMapOf.I found this by running
org.openrewrite.java.migrate.util.UseMapOffromorg.openrewrite.recipe:rewrite-migrate-java:3.40.0onPromptRenderer.javain Symphony-Trello ata8013f27. I reproduced the same result with the latest released recipe artifact,org.openrewrite.recipe:rewrite-migrate-java:3.42.0. The original target test passes. After the recipe,WorkflowConfigPromptTest.missingWorkflowAndUnknownTemplateVariablesUseTypedErrorsfails becauseattempt == nullreachesMap.ofand throwsNullPointerExceptionbefore the expected application error is created.Before
Actual after the recipe
Expected after the recipe
(unchanged)HashMap.putaccepts null values, whileMap.ofrejects them. The recipe silently changes the first-attempt runtime behavior from a typed application error toNullPointerException.Confirmed real-world execution
PromptRenderer.javaata8013f27.martinfrancois/symphony-trello@a8013f27.Anything in particular you'd like reviewers to focus on?
Please review the conservative non-null proof. An expression with unknown nullability remains unchanged instead of being treated as non-null without data-flow evidence.
Have you considered any alternatives or workarounds?
Adding a sentinel for null would change the application's prompt contract. Leaving only the unsafe conversion unchanged preserves behavior without changing the recipe's safe cases.
Any additional context
Pre-existing tests changed: None.
martinfrancois/symphony-trello@a8013f27org.openrewrite.recipe:rewrite-migrate-java:3.40.0org.openrewrite.recipe:rewrite-migrate-java:3.42.0NullPointerExceptionUseMapOfTestThis change was prepared with AI assistance. I reviewed the target execution evidence, implementation, tests, and contribution text.
Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv