Skip to content

Unit test failures on Go 1.27 #2502

Description

@supakeen

On Go 1.27 part of our unittests fails as the default json encoder has been changed. Thus some error messages have changed:

The encoding/json package is now backed by the v2 implementation. Marshaling and unmarshaling behavior is preserved, but the exact text of error messages may differ

--- FAIL: TestFsNodeUnmarshalBadFile (0.00s)
    fsnode_test.go:256: 
        	Error Trace:	/builddir/build/BUILD/image-builder-74.0.0-build/image-builder-74.0.0/_build/src/github.com/osbuild/image-builder/pkg/customizations/fsnode/fsnode_test.go:256
        	Error:      	Expect "unmarshal yaml via json for {"path":123} failed: json: cannot unmarshal number into Go struct field .path of type string" to match "json: cannot unmarshal number into Go struct field .*.Path of type string"
        	Test:       	TestFsNodeUnmarshalBadFile
    fsnode_test.go:256: 
        	Error Trace:	/builddir/build/BUILD/image-builder-74.0.0-build/image-builder-74.0.0/_build/src/github.com/osbuild/image-builder/pkg/customizations/fsnode/fsnode_test.go:256
        	Error:      	Expect "unmarshal yaml via json for {"mode":"-rw-rw-r--"} failed: json: cannot unmarshal string into Go struct field .mode of type fs.FileMode" to match " json: cannot unmarshal string into Go struct field .*.Mode of type fs.FileMode"
        	Test:       	TestFsNodeUnmarshalBadFile
    fsnode_test.go:256: 
        	Error Trace:	/builddir/build/BUILD/image-builder-74.0.0-build/image-builder-74.0.0/_build/src/github.com/osbuild/image-builder/pkg/customizations/fsnode/fsnode_test.go:256
        	Error:      	Expect "unmarshal yaml via json for {"mode":-1} failed: json: cannot unmarshal number -1 into Go struct field .mode of type fs.FileMode" to match "cannot unmarshal number -1 into Go struct field .*.Mode of type fs.FileMode"
        	Test:       	TestFsNodeUnmarshalBadFile
    fsnode_test.go:256: 
        	Error Trace:	/builddir/build/BUILD/image-builder-74.0.0-build/image-builder-74.0.0/_build/src/github.com/osbuild/image-builder/pkg/customizations/fsnode/fsnode_test.go:256
        	Error:      	Expect "unmarshal yaml via json for {"mode":5000000000} failed: json: cannot unmarshal number 5000000000 into Go struct field .mode of type fs.FileMode" to match "json: cannot unmarshal number 5000000000 into Go struct field .*.Mode of type fs.FileMode"
        	Test:       	TestFsNodeUnmarshalBadFile

This seems to be the only test case that's failing so converting strings to lower case might be the apt way to deal with this.

Note that Go 1.27 has landed in rawhide thus we're seeing these issues now.

We'll also need to start running tests on rawhide in upstream see #2500 for that part.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ciRelated to the CI setup.area/packagingRelated to packaging.bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions