relaton / relaton-bib

MIT License
3 stars 1 forks source link

(URGENT) Crash with relaton-cli concatenate command #21

Closed ronaldtse closed 4 years ago

ronaldtse commented 4 years ago

This can be reproduced in this repo:

https://gitlab.com/calconnect/tc-datetime/csd-timezone-model

Trace:

NoMethodError: undefined method `[]' for nil:NilClass
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-bib-0.6.0/lib/relaton_bib/xml_parser.rb:20:in `item_data'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-iso-bib-0.6.0/lib/relaton_iso_bib/xml_parser.rb:22:in `item_data'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-itu-0.6.0/lib/relaton_itu/xml_parser.rb:12:in `from_xml'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-itu-0.6.0/lib/relaton_itu/processor.rb:23:in `from_xml'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli.rb:38:in `parse_xml'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/bibdata.rb:49:in `from_xml'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:185:in `bibdata_instance'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:146:in `block in concatenate_files'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:138:in `map'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:138:in `concatenate_files'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:86:in `bibcollection'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:151:in `concatenate_and_write_to_files'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:19:in `concatenate'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/relaton_file.rb:58:in `concatenate'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli/command.rb:33:in `concatenate'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/lib/relaton/cli.rb:20:in `start'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/relaton-cli-0.6.0/exe/relaton:20:in `<top (required)>'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bin/relaton:23:in `load'
  /Users/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bin/relaton:23:in `<top (required)>'
make: *** [documents.rxl] Error 1
ronaldtse commented 4 years ago

This indicates that we don't have enough testing for the Relation suite. @andrew2net could you please help add appropriate tests? Thanks.

andrew2net commented 4 years ago

Added warning in case XML parser doesn't find bibitem or bibdata element.