liquibase: Regression 4.5.0 -> 4.6.1: valueBlobFile fails with "BLOB resource not found"

Environment

Liquibase Version: 4.6.1

Liquibase Integration & Version: Spring Boot 2.1.18.RELEASE

Database Vendor & Version: H2 1.4.200 (in-memory)

Operating System Type & Version: macOS Catalina (10.15.7)

Description

Spring Boot application can’t start and fails with an exception.

Steps To Reproduce

Run an application with ./mvnw spring-boot:run

Actual Behavior

liquibase.exception.MigrationFailedException: Migration failed for change set liquibase/version/0.4/2017-05-29--test_image.xml::add-test-image::php-coder:
     Reason: liquibase.exception.DatabaseException: BLOB resource not found: /test/test.png

Expected/Desired Behavior

Migration should work as it worked before.

Additional Context

It has happened when I upgraded Liquibase from 4.5.0 to 4.6.1

Migration that has failed:

	<changeSet id="add-test-image" author="php-coder" context="test-data">
		
		<insert tableName="images_data">
			<column name="image_id" valueNumeric="1" />
			<column name="content" valueBlobFile="/test/test.png" />
		</insert>
		
	</changeSet>

See https://github.com/php-coder/mystamps/blob/4fd2d3b6c89cd06dcc027a7239233ab78be8b895/src/main/resources/liquibase/version/0.4/2017-05-29--test_image.xml

The file it looks for (/test/test.png) is here: src/main/resources/test/test.png

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

@famod said:

I bisected my way through this and ended up here: ba64243, so #2114 seems to have broken it.

Yes, I agree. liquibase.util.file.FilenameUtils#concat()` in Liquibase 4.5.0 documents its contract:

     * /foo + bar           -->   /foo/bar
     * /foo + /bar          -->   /bar

The newer liquibase.util.FilenameUtil#concat() since Liquibase 4.6.0 does not document its contract and none of the tests use an absolute path for the second parameter, but the method behaves differently:

     * /foo + bar           -->   /foo/bar
     * /foo + /bar          -->   /foo/bar

@nvoxland Could you please clarify if/how liquibase.util.FilenameUtil#concat() is intended to handle absolute paths for its second parameter?

Good point if that’s the case (haven’t checked).

Btw, @php-coder I didn’t pay full attention to where your changelog file is located exactly. Since it’s located in /src/main/resources/liquibase/version/0.4/, you have to step up three levels: ../../../test/test.png But then again you probably don’t want to change your past changelogs anyway, right? 😉

Workaround: prepend ..! E.g. ../foo.bar or ../db/foo.bar. Or for your case @php-coder: ../test/test.png

/cc @nvoxland