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

MergeYaml can not parse valid yaml #4794

Open
dpozinen opened this issue Dec 17, 2024 · 2 comments
Open

MergeYaml can not parse valid yaml #4794

dpozinen opened this issue Dec 17, 2024 · 2 comments
Labels
bug Something isn't working recipe Requested Recipe test provided Already replicated with a unit test, using JUnit pioneer's ExpectedToFail

Comments

@dpozinen
Copy link
Contributor

dpozinen commented Dec 17, 2024

When using MergeYaml with @:@ in the value open rewrite cannot parse the yaml, even though it is valid,
it appears this is because of changes introduced in 8b705c3
specifically this regex:

private static final Pattern VARIABLE_PATTERN = Pattern.compile(":\\s*(@[^\n\r@]+@)");

which causes UUID replacements

Here's a test to reproduce:

rewriteRun(
    spec -> spec.recipe(new MergeYaml(
      "$",
      """
          container:
              docker-image-name: "${@project.groupId@/@service.name@:@project.version@}"
              """,
      null, null,null)
    ),
    yaml(
      """
          container:
              a: b
      """,
      """
          container:
              a: b
              docker-image-name: "${@project.groupId@/@service.name@:@project.version@}"
      """
    )
  );

results in:

java.lang.ClassCastException: class org.openrewrite.tree.ParseError cannot be cast to class org.openrewrite.yaml.tree.Yaml$Documents (org.openrewrite.tree.ParseError and org.openrewrite.yaml.tree.Yaml$Documents are in unnamed module of loader 'app')
@dpozinen dpozinen added the bug Something isn't working label Dec 17, 2024
@timtebeek timtebeek added the test provided Already replicated with a unit test, using JUnit pioneer's ExpectedToFail label Dec 17, 2024
@timtebeek
Copy link
Contributor

Thanks for providing that context link and a runnable example; did you already explore any possible fix?

@timtebeek timtebeek moved this to Backlog in OpenRewrite Dec 17, 2024
@timtebeek timtebeek added the recipe Requested Recipe label Dec 17, 2024
@dpozinen
Copy link
Contributor Author

not really, i messed around a bit with the regex, I might have a look more today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working recipe Requested Recipe test provided Already replicated with a unit test, using JUnit pioneer's ExpectedToFail
Projects
Status: Backlog
Development

No branches or pull requests

2 participants