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

ChangePropertyValue automatically coalesces properties #3426

Open
wabrit opened this issue Jul 19, 2023 — with Slack · 5 comments
Open

ChangePropertyValue automatically coalesces properties #3426

wabrit opened this issue Jul 19, 2023 — with Slack · 5 comments
Labels
bug Something isn't working test provided Already replicated with a unit test, using JUnit pioneer's ExpectedToFail

Comments

Copy link

wabrit commented Jul 19, 2023

Given a source YAML that looks like this:

quarkus:
  opentelemetry:
    enabled: true

and a recipe ChangePropertyKey("quarkus.opentelemetry.enabled", "quarkus.otel.enabled", ..)

the result is

quarkus:
  otel.enabled: true

This automatic coalescing of property names confuses Quarkus, which treats the new property as quarkus."otel.enabled" and doesn't match it to quarkus.otel.enabled.

The correct output in this case would be:

quarkus:
  otel:
    enabled: true
@wabrit
Copy link
Author

wabrit commented Jul 19, 2023

The following simple failing test should demonstrate the issue:

class ChangePropertyKeyTest implements RewriteTest {

    @Test
    void simpleTest() {
        rewriteRun(
            spec -> spec.recipe(
                new ChangePropertyKey("quarkus.opentelemetry.enabled", "quarkus.otel.enabled",
                        null, "application.yml", null)
            ),
            yaml(
                """
                     quarkus:
                       foo:
                         bar: 1
                       opentelemetry:
                         enabled: true
                         
                    """,
                """
                    quarkus:
                       foo:
                         bar: 1
                       otel:
                         enabled: true
                         
                   """,
                spec -> spec.path("application.yml")
            )
        );
    }

@timtebeek
Copy link
Contributor

Hmm; what version of OpenRewrite are you using? Since that "application.yml" causes a compiler error on the main branch.

@timtebeek timtebeek added the bug Something isn't working label Jul 19, 2023
@timtebeek timtebeek moved this to Backlog in OpenRewrite Jul 19, 2023
@timtebeek
Copy link
Contributor

Either way confirmed to be an issue also without that argument ; not clear yet what the fix should be unfortunately, so this goes onto the backlog.

@wabrit
Copy link
Author

wabrit commented Jul 19, 2023

Hmm; what version of OpenRewrite are you using? Since that "application.yml" causes a compiler error on the main branch.

This is not latest major release; will check tomorrow when i have access to the code and record it here.

@timtebeek timtebeek added the test provided Already replicated with a unit test, using JUnit pioneer's ExpectedToFail label Jul 20, 2023
@timtebeek
Copy link
Contributor

Previously seen on #1841

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

No branches or pull requests

2 participants