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

Change GradleDependency recipe throws recipe validation error #5105

Open
andyvady opened this issue Feb 28, 2025 · 2 comments
Open

Change GradleDependency recipe throws recipe validation error #5105

andyvady opened this issue Feb 28, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@andyvady
Copy link

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.47.1
  • Gradle v8.12.1
  • rewrite-gradle v8.47.3

How are you running OpenRewrite?

Single module project. Using rewrite-gradle plugin

Can you share your configuration so that we can rule out any configuration issues?
Copied sample spec from https://docs.openrewrite.org/recipes/gradle/changedependency#usage


type: specs.openrewrite.org/v1beta/recipe
name: com.yourorg.ChangeDependencyExample
displayName: Change Gradle dependency example
recipeList:

  • org.openrewrite.gradle.ChangeDependency:
    oldGroupId: org.openrewrite.recipe
    oldArtifactId: rewrite-testing-frameworks
    newGroupId: corp.internal.openrewrite.recipe
    newArtifactId: rewrite-testing-frameworks
    newVersion: 29.X
    versionPattern: '-jre'

Is your project public? If so, can you share a link to it?
Executed the sample recipe via IntelliJ using OpenRewrite plugin

What is the smallest, simplest way to reproduce the problem?

What did you expect to see?

Expected to see the recipe executed successfully, even if there were no changes to report.

What did you see instead?

Exception on execution

What is the full stack trace of any errors you encountered?

Recipe validation error in org.openrewrite.gradle.ChangeDependency: Unable to load Recipe: java.lang.IllegalArgumentException: Cannot find a (Map) Key deserializer for type [simple type, class org.openrewrite.maven.tree.ResolvedDependency]
 at [Source: UNKNOWN; byte offset: #UNKNOWN]
Recipe validation errors detected as part of one or more activeRecipe(s). Execution will continue regardless.
All sources parsed, running active recipes: com.yourorg.ChangeDependencyExample
@andyvady andyvady added the bug Something isn't working label Feb 28, 2025
@andyvady
Copy link
Author

andyvady commented Feb 28, 2025

Tried the Run this recipe here feature and it fails with the same exception: link

java.io.UncheckedIOException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a (Map) Key deserializer for type [simple type, class org.openrewrite.maven.tree.Dependency] at [Source: UNKNOWN; byte offset: #UNKNOWN] Caused by com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a (Map) Key deserializer for type [simple type, class org.openrewrite.maven.tree.Dependency] at [Source: UNKNOWN; byte offset: #UNKNOWN] com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67) com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1887) com.fasterxml.jackson.databind.deser.DeserializerCache._handleUnknownKeyDeserializer(DeserializerCache.java:638) com.fasterxml.jackson.databind.deser.DeserializerCache.findKeyDeserializer(DeserializerCache.java:198) com.fasterxml.jackson.databind.DeserializationContext.findKeyDeserializer(DeserializationContext.java:696) com.fasterxml.jackson.databind.deser.std.MapDeserializer.createContextual(MapDeserializer.java:314) com.fasterxml.jackson.databind.DeserializationContext.handlePrimaryContextualization(DeserializationContext.java:851) com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:561) ...

Image

@knutwannheden
Copy link
Contributor

knutwannheden commented Mar 1, 2025

The problem here is that we are using Jackson to update the recipe options and this recipe happens to have some transient fields, which Jackson chokes on. We should invoke this method on the MapperBuilder: configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true).

Also note that it is not only the fact that the recipe has a transient field that causes trouble. It is also that this field is of a Map type for which no key serializer has been registered with the Map's key type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants