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

YAMLChangelogParser: Fix parsing logic around changeLogId in a Map #2168

Merged
merged 1 commit into from Nov 16, 2021

Conversation

nvoxland
Copy link
Contributor

@nvoxland nvoxland commented Oct 29, 2021

Description

Fixes #1988

Problem code was caused by an incorrect merge in the changeLogId handling, so I fixed the if statement nesting to be correct.


Dev Handoff Notes (Internal Use)

Links

Testing

  • Steps to Reproduce: Invalid Yaml throws ClassCastExceptions #1988
  • Guidance:
    • Impact: database independent
    • Moves a setting of changeLogId into a more logical spot in the code. The code got triggered in an invalid yaml like in the reported bug, I'm not sure what valid ways hit that spot. Maybe there are none and it's just invalid code? The valid yaml files I tried ended up setting changeLogId via a different part of the code than the part that changed.
    • The code was obviously merged wrong, and a straightforward move
    • Fix is purely in the yaml parsing code, so just testing an update command is all that is needed

Dev Verification

Ran update with various valid and invalid yaml files to see what sort of errors we get. We no longer can get the ClassCastException that the issue reported. Validation of invalid yaml files in general can be improved, but that would be a much larger project

Error Message
liquibase.exception.CommandExecutionException: 
liquibase.exception.LiquibaseException: 
Unexpected error running Liquibase: 
class java.util.ArrayList cannot be cast to class java.util.Map 

Test Requirements (Liquibase Internal QA)

The bug being addressed in this fix impacted only YAML changelogs with an invalid changelog format. Any database platform can be used for testing. However, repro validation was done against a MySQL database.

Manual Tests

Verify update-sql with an invalid YAML changelog does not throw a class cast exception.

liquibase --log-level INFO update-sql --changelog-file lb2123-invalid-changelog.yml

  • The update-sql is successful.
  • There is no class cast exception.
  • The update-sql output shows Lock Database and Release Database Lock messages.
    • There are no changesets to deploy in lb2123-invalid-changelog.yml.

Verify update with an invalid YAML changelog does not throw a cast cast exception.

liquibase --log-level INFO update --changelog-file lb2123-invalid-changelog.yml

  • The update is successful.
  • There is no class cast exception.
  • The console output shows successfully acquired change log lock
  • The console output shows successfully released change log lock
    • No changes are deployed as there are no change sets in the invalid changelog.

Verify update-sql with a valid YAML changelog does not throw a class cast exception.

liquibase --log-level INFO update-sql --changelog-file lb2123-valid-changelog.yml

  • The update-sql is successful.
  • There is no class cast exception.
  • The update-sql output shows SQL to create the table account

Verify update with a valid YAML changelog does not throw a class cast exception.

liquibase --log-level INFO update --changelog-file lb2123-valid-changelog.yml

  • The update is successful.
  • There is no class cast exception.
  • The console output shows that changeset myfilepath::1603997898589-1::gemfire (generated) ran successfully.
  • The table account exists on the database.

Automated Tests

  • None required for this ticket.

┆Issue is synchronized with this Jira Bug by Unito

@nvoxland nvoxland changed the title Correctly set changeLogId in yaml changelog files YAMLChangelogParser: Fix parsing logic around changeLogId in a Map Oct 29, 2021
@nvoxland nvoxland added this to To Do in Conditioning++ via automation Oct 29, 2021
@nvoxland nvoxland moved this from To Do to Code Review in Conditioning++ Oct 29, 2021
@suryaaki2 suryaaki2 self-requested a review October 29, 2021 17:54
@suryaaki2 suryaaki2 moved this from Code Review to Ready for Handoff (In JIRA) in Conditioning++ Oct 29, 2021
@suryaaki2 suryaaki2 merged commit 8e2914d into master Nov 16, 2021
Conditioning++ automation moved this from Ready for Handoff (In JIRA) to Done Nov 16, 2021
@suryaaki2 suryaaki2 deleted the yaml-changelog-id branch November 16, 2021 21:57
@nvoxland nvoxland removed this from Done in Conditioning++ Dec 1, 2021
@nvoxland nvoxland added this to the v4.6.2 milestone Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid Yaml throws ClassCastExceptions
3 participants