elliotchance / gedcom

👪 A Go library and CLI tools for encoding, decoding, traversing, merging, comparing, querying and publishing GEDCOM files.
MIT License
97 stars 22 forks source link

Warnings command panic #316

Open jeff-bonevich opened 4 years ago

jeff-bonevich commented 4 years ago

I am getting an interesting error when running warnings on a gedcom I exported from Ancestry:

panic: indent is too large - missing parent? at line 532879: 2 SOUR @S1140445012@

goroutine 1 [running]:
github.com/elliotchance/gedcom.(*Decoder).Decode(0xc0004fbd58, 0x1000, 0x1000, 0xc0000b9000)
        /home/travis/gopath/src/github.com/elliotchance/gedcom/decoder.go:149 +0x9ec
github.com/elliotchance/gedcom.NewDocumentFromGEDCOMFile(0x7ffeefbffa64, 0x18, 0x1, 0x1, 0x0)
        /home/travis/gopath/src/github.com/elliotchance/gedcom/document.go:238 +0x18b
main.runWarningsCommand()
        /home/travis/gopath/src/github.com/elliotchance/gedcom/cmd/gedcom/warnings.go:21 +0x1d2
main.main()
        /home/travis/gopath/src/github.com/elliotchance/gedcom/cmd/gedcom/main.go:56 +0x28c

Only line 532879 does not contain the text '2 SOUR @S1140445012@'. That text does appear in the file 100's of times, but not at that particular position. So not certain I am understanding the error at all. Not certain if this is a known issue with Ancestry exports or a bug.

elliotchance commented 4 years ago

This is because Ancestry does not export valid GEDCOM when text has newlines. Newlines are supposed to be split into CONT nodes. There is a solution for this: https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/diff.go#L142-L154

Unfortunately, I haven't added the same CLI option to the warnings command. Would you like to fix it in a PR?

elliotchance commented 4 years ago

Actually, it may be related to this: https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/diff.go#L156-L169 either way the fix is basically the same - the engine supports it but theres no CLI option through warnings to turn that feature on.