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

Regression in Liquibase 4.25.0: Liquibase#calculateCheckSum() always fails #5225

Closed
1 of 2 tasks
joschi opened this issue Nov 15, 2023 · 2 comments · Fixed by #5235
Closed
1 of 2 tasks

Regression in Liquibase 4.25.0: Liquibase#calculateCheckSum() always fails #5225

joschi opened this issue Nov 15, 2023 · 2 comments · Fixed by #5235
Assignees
Labels

Comments

@joschi
Copy link

joschi commented Nov 15, 2023

Search first

  • I searched and no similar issues were found

Description

The changes in #4463 cause Liquibase#calculateCheckSum() to always fail with the error message:

Error encountered while parsing the command line. '--changeset-identifier' cannot be provided alongside other changeset arguments: '--changeset-id', '--changeset-path', '--changeset-author'.

Looks like this check is responsible for the error message:
https://github.com/liquibase/liquibase/blame/v4.25.1/liquibase-standard/src/main/java/liquibase/command/core/CalculateChecksumCommandStep.java#L140-L142

The command is always constructed with

CalculateChecksumCommandStep.CHANGESET_PATH_ARG, CalculateChecksumCommandStep.CHANGESET_ID_ARG, CalculateChecksumCommandStep.CHANGESET_AUTHOR_ARG, and CalculateChecksumCommandStep.CHANGESET_IDENTIFIER_ARG which triggers the exception:

https://github.com/liquibase/liquibase/blob/v4.25.1/liquibase-standard/src/main/java/liquibase/Liquibase.java#L1271-L1278

Steps To Reproduce

With Liquibase 4.25.0:

@Test
void liquibasePullRequest4463() throws LiquibaseException {
  Liquibase liquibase = new Liquibase("migrations.xml", new ClassLoaderResourceAccessor(), new H2Database());
  liquibase.calculateCheckSum("", "1", "name");
}

Exception:

liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: java.lang.IllegalArgumentException: Error encountered while parsing the command line. '--changeset-identifier' cannot be provided alongside other changeset arguments: '--changeset-id', '--changeset-path', '--changeset-author'.

	at liquibase.command.CommandScope.execute(CommandScope.java:237)
	at liquibase.Liquibase.calculateCheckSum(Liquibase.java:1278)
	at com.github.joschi.liquibase.DbCalculateChecksumCommandTest.liquibasePullRequest4463(DbCalculateChecksumCommandTest.java:47)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Caused by: liquibase.exception.LiquibaseException: java.lang.IllegalArgumentException: Error encountered while parsing the command line. '--changeset-identifier' cannot be provided alongside other changeset arguments: '--changeset-id', '--changeset-path', '--changeset-author'.
	at liquibase.command.core.CalculateChecksumCommandStep.validateIdentifierParameters(CalculateChecksumCommandStep.java:148)
	at liquibase.command.core.CalculateChecksumCommandStep.run(CalculateChecksumCommandStep.java:95)
	at liquibase.command.CommandScope.execute(CommandScope.java:214)
	... 5 more
Caused by: java.lang.IllegalArgumentException: Error encountered while parsing the command line. '--changeset-identifier' cannot be provided alongside other changeset arguments: '--changeset-id', '--changeset-path', '--changeset-author'.
	... 8 more

Expected/Desired Behavior

The checksum of the changeset should be calculated without an exception.

Liquibase Version

4.25.0

Database Vendor & Version

All

Liquibase Integration

Code (via liquibase.Liquibase)

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
@filipelautert
Copy link
Collaborator

@joschi you are right, this change really broke the API and we will need to fix it. Meanwhile, would you mind switching to the new command framework that is used by this method? You could replace the method being called by:

 CommandResults commandResults = new CommandScope("calculateChecksum")
                .addArgumentValue(DbUrlConnectionCommandStep.DATABASE_ARG, database)
                .addArgumentValue(CalculateChecksumCommandStep.CHANGESET_PATH_ARG, changeSetPath)
                .addArgumentValue(CalculateChecksumCommandStep.CHANGESET_ID_ARG, changeSetId)
                .addArgumentValue(CalculateChecksumCommandStep.CHANGESET_AUTHOR_ARG, changeSetAuthor)
                .addArgumentValue(CalculateChecksumCommandStep.CHANGELOG_FILE_ARG, this.changeLogFile)
                .execute();

We will get it fixed for the next release.

@tati-qalified
Copy link
Contributor

Hi @joschi, the fix is completed and will be added to the next release. Thank you for reporting the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants