fix!: require the compiler plugin marker for interpolation safety and fail fast on unknown modes - #434
Merged
Merged
Conversation
… fail fast on unknown modes Explicit t() or interpolate() calls no longer satisfy the interpolation safety check: a single call exempted the whole template, letting every other raw interpolation pass silently. A raw interpolation is plain string concatenation by the time the lambda runs, so the plugin marker is the only signal that can verify a template; without it, the configured mode now always applies. The mode switch is exhaustive: warn, fail and none are matched after trimming and case normalization, and any other value throws an IllegalStateException naming the valid values instead of silently disabling the check. The disabled mode is spelled none, matching the documentation. storm-kotlinx-serialization compiles its tests with the compiler plugin so its template lambdas carry the marker. Fixes #392
…mpiler plugin resolves from the reactor
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Closes the three gaps in the interpolation safety backstop (#392):
t()no longer exempts the template. Counting interpolations againstt()calls is not implementable at runtime: a raw$nameis plain string concatenation by the time the lambda executes, so nothing observable distinguishes it from literal SQL text. The sound contract is that the compiler plugin marker is the only verification signal; templates built without it now always trigger the configured mode. The mixed template from the issue warns (or fails) instead of passing silently.IllegalStateExceptionnaming the valid values instead of silently disabling the check. Matching is trimmed and case-insensitive, like the record and schema validation modes. (Unknown-value handling for those two siblings is inconsistent in opposite directions; filed as Validation modes: unknown values silently skip schema validation and silently escalate record validation #433.)none, matching the documentation; the strayoffspelling is gone.The default mode stays
warn; flipping the default tofailwas flagged in the issue as possibly too breaking for this milestone. Instead the production hardening docs now state plainly that production deployments using Kotlin templates should setfail, sincewarnreduces a missing compiler plugin to a log line.Breaking behavior changes
t()calls (previously silent). The warning is logged once per JVM: one occurrence identifies the problem and the remedy is global, so repeating it per template would only flood the logs of applications that wrap interpolations manually. Remedy: apply the compiler plugin, or set-Dstorm.validation.interpolation_mode=nonewhen every interpolation is wrapped manually.Repository CRUD and the typed query DSL are unaffected: the check runs only when a
TemplateBuilderlambda is built, and the mode property is only consulted for templates without the marker.storm-kotlinx-serialization now compiles its tests with the compiler plugin; its integration tests build template lambdas with explicit
t()and would otherwise warn under the new semantics.Docs:
docs/string-templates.mdanddocs/configuration.mdupdated (docs/ only, so the change shows at/docs/nextand goes live with the next release snapshot).Tested: new
InterpolationSafetyTest(9 tests) uses namedTemplateContextextension functions, which the plugin transformer leaves untouched, to model plugin-less templates inside a plugin-compiled module. Full storm-kotlin (1712) and storm-kotlinx-serialization (192) suites green.Fixes #392