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

Panic when comparing idential files with integer #318

Closed
ywei2017 opened this issue May 19, 2020 · 1 comment · Fixed by #319
Closed

Panic when comparing idential files with integer #318

ywei2017 opened this issue May 19, 2020 · 1 comment · Fixed by #319

Comments

@ywei2017
Copy link
Contributor

version 1.25.2.

When

  • comparing two identical files, AND
  • if one array key is "id", AND
  • the value is number, with the same value between the files, then
    it panics.
~: 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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant