geofffranks / spruce

A BOSH template merge tool
MIT License
433 stars 78 forks source link

Panic when comparing idential files with integer #318

Closed ywei2017 closed 4 years ago

ywei2017 commented 4 years ago

version 1.25.2.

When

~: for fn in f*.yml; do echo ">>>> $fn <<<<"; cat $fn; done
>>>> f1.yml <<<<
meta:
- id: 123
>>>> f2.yml <<<<
meta:
- id: 123
>>>> f3.yml <<<<
meta:
- id: 456
>>>> f4.yml <<<<
meta:
- id: "123"
>>>> f5.yml <<<<
meta:
- id_num: 123

~: spruce diff f1.yml f3.yml

meta
  - one list entry removed:     + one list entry added:
    - id: 123                     - id: 456

~: spruce diff f4.yml f4.yml

~: spruce diff f5.yml f5.yml

~: spruce diff f1.yml f1.yml
panic: interface conversion: interface {} is int, not string

goroutine 1 [running]:
github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff.compareNamedEntryLists(0x0, 0xc0001ca2d0, 0x1, 0x1, 0xb7544d, 0x2, 0xc0001ce160, 0x1, 0x1, 0xc0001963b0, ...)
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff/core.go:289 +0xf1e
github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff.compareLists(0x0, 0xc0001ca2d0, 0x1, 0x1, 0xc0001ce160, 0x1, 0x1, 0xc0001963b0, 0x1, 0x1, ...)
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff/core.go:186 +0x359
github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff.compareObjects(0x0, 0xc0001ca2d0, 0x1, 0x1, 0xa5ddc0, 0xc0001f21c0, 0xa5ddc0, 0xc00000b620, 0x1, 0x1, ...)
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff/core.go:112 +0x6b3
github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff.compareMapSlices(0x0, 0x0, 0x0, 0x0, 0xc0001f21e0, 0x1, 0x1, 0xc00000b640, 0x1, 0x1, ...)
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff/core.go:142 +0xb2e
github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff.compareObjects(0x0, 0x0, 0x0, 0x0, 0xa927c0, 0xc0001f2220, 0xa927c0, 0xc00000b680, 0x1, 0x1, ...)
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff/core.go:109 +0xdfe
github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff.CompareInputFiles(0x7fffb8010116, 0x6, 0x0, 0x0, 0xc0001ce120, 0x1, 0x1, 0x7fffb801011d, 0x6, 0x0, ...)
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/vendor/github.com/homeport/dyff/pkg/v1/dyff/core.go:81 +0x1d8
main.diffFiles(0xc00000b420, 0x2, 0x2, 0x4, 0x0, 0x0, 0xc0001a65b5, 0x1154960)
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/cmd/spruce/main.go:529 +0x258
main.main()
        /tmp/build/01f561ac/gopath/src/github.com/geofffranks/spruce/cmd/spruce/main.go:192 +0x333
ywei2017 commented 4 years ago

ok, I think I find out the reason. The panic is due to old version of dyff (0.10.1). I was able to repeat the panic message using the dyff v0.10.1 standalone utility. I can also confirm that the latest dyff version doesn't suffer the same problem.

So an update of the dependency to 1.0.2 should solve the issue.

Thanks Yansheng