Skip to content

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

Closed
@joschi

Description

@joschi

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!)

Activity

moved this from New to Candidate in Liquibase Open Sourceon Nov 16, 2023
filipelautert

filipelautert commented on Nov 16, 2023

@filipelautert
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.

self-assigned this
on Nov 16, 2023
tati-qalified

tati-qalified commented on Nov 21, 2023

@tati-qalified
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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status

    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Regression in Liquibase 4.25.0: Liquibase#calculateCheckSum() always fails · Issue #5225 · liquibase/liquibase