Detect missing MongoDB value representations - #1098
Open
Kyran121 wants to merge 3 commits into
Open
Conversation
Kyran121
force-pushed
the
detect-mongodb-value-representations
branch
7 times, most recently
from
July 25, 2026 16:57
1a1cda7 to
8b67552
Compare
Kyran121
force-pushed
the
detect-mongodb-value-representations
branch
from
August 2, 2026 00:10
55b2bc6 to
37c8625
Compare
Kyran121
added a commit
to Kyran121/rewrite-spring
that referenced
this pull request
Aug 2, 2026
UpgradeSpringDataMongoDb_5_0RepresentationTest still asserted the removed class-level fallback marker, which is what broke CI on PR openrewrite#1098; updated to expect the baseline-file generation it was replaced by. Manual end-to-end testing against a real Gradle rewriteRun (not just RewriteTest) surfaced three further correctness issues invisible to the unit suite: - SearchResult markers on invalid property/YAML/Java entries were printed as literal `~~(...)~~>` text in real (non-dry-run) output, contrary to SearchResult's own contract. For properties this was destructive: everything before `=` becomes the key, silently deleting the flagged property. Now relies solely on the real, persisted Comments.of(...) comment already used alongside it. - Recipe.causesAnotherCycle() defaults to false, so a real invocation stopped right after generating a baseline configuration file, before the following cycle that populates it ever ran, leaving a 0-byte file. Now overridden to true. - Suggested properties were created with placeholder text ("<representation>") that could crash Spring Boot's config binding on startup if never followed up on. Both formats now use a real, safely-bindable UNSPECIFIED value instead — the same state a user explicitly writing UNSPECIFIED would produce, so it's detected and commented via the existing, already-tested invalid-value path instead of a separate "missing" one. Simplified as a result: - YAML suggestions merge into the document as proper nested mappings via the existing AddSpringProperty (which already dispatches per-format internally) instead of a hand-rolled MergeYaml call duplicating that same logic. - AddSpringProperty's comment parameter attaches the diagnostic comment at creation time instead of deferring it to a follow-up cycle, cutting a cycle off both the existing-config-file and baseline-generation cases. - Removed now-redundant comments and duplicated deferred-finalization logic (extracted into a single finalizeUnless helper) in favor of names and structure that carry the same intent. Verified against real dummy Spring projects via the actual Gradle plugin, not just the unit test harness. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Kyran121
force-pushed
the
detect-mongodb-value-representations
branch
from
August 2, 2026 23:43
9b23f96 to
47df833
Compare
8 tasks
Kyran121
force-pushed
the
detect-mongodb-value-representations
branch
from
August 3, 2026 17:42
47df833 to
f179acd
Compare
Kyran121
marked this pull request as ready for review
August 3, 2026 19:26
Contributor
Author
|
@timtebeek - ready to review |
Adds FindMissingMongoValueRepresentation, a project-scoped diagnostic recipe that finds explicitly MongoDB-mapped UUID, BigDecimal, and non-ID BigInteger fields requiring an explicit value representation on Spring Data MongoDB 5, reporting them via the MongoValueRepresentationFields data table. It's composed into UpgradeSpringDataMongoDb_5_0. - Suggests a real, safely-bindable UNSPECIFIED property (merged into the document as proper nested YAML mappings, or a plain properties entry) with an explanatory comment, in the project's main application*.properties/.yml/.yaml, or a generated baseline file when none exists. - Flags blank, malformed, unsupported, or UNSPECIFIED values with a real, persisted comment directly on the offending Java, properties, or YAML source, rather than a transient marker. - Recognises valid configuration (including relaxed spellings and property placeholders) across Java, properties, and YAML, and flags invalid profile overrides even when a valid default exists elsewhere. - Idempotent both within a single run and across separate invocations. Verified via the unit test suite and against real dummy Spring projects through the actual Gradle plugin, not just the test harness. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Kyran121
force-pushed
the
detect-mongodb-value-representations
branch
from
August 17, 2026 21:14
f179acd to
7e7eeb5
Compare
…representations # Conflicts: # src/main/resources/META-INF/rewrite/recipes.csv
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.
What changed
FindMissingMongoValueRepresentation, a project-scoped diagnostic recipe for Spring Data MongoDB 5 migrations.UUID,BigDecimal, and non-IDBigIntegerfields that require an explicit value representation, including nested collection and map-value types, and report every affected field in theMongoValueRepresentationFieldsdata table..properties, and YAML, including relaxed value spellings and property placeholders. Test-source configuration does not suppress main-source diagnostics, and invalid profile overrides are still reported when a valid default exists.UNSPECIFIEDand an explanatory comment to the preferred mainapplication*.properties/.yml/.yamlfile. Generatesrc/main/resources/application.propertieswhen the project has no suitable configuration file.null, or explicitlyUNSPECIFIED, add a persisted comment directly to the offending source rather than relying on a transient search marker.UNSPECIFIEDwith the value matching their existing BSON data.UpgradeSpringDataMongoDb_5_0and register the recipe metadata.Validation
Closes #1083.
Part of #1081.