relaton / relaton-bib

MIT License
3 stars 1 forks source link

lib/relaton_bib/copyright_association.rb:59:in `to_hash': undefined method `year' for nil:NilClass (NoMethodError) #40

Closed CAMOBAP closed 3 years ago

CAMOBAP commented 3 years ago

https://github.com/metanorma/mn-samples-bipm/pull/30/checks?check_run_id=1982120757

2021-02-25T19:59:10.1782851Z /usr/local/bundle/gems/relaton-bib-1.7.1/lib/relaton_bib/copyright_association.rb:59:in `to_hash': undefined method `year' for nil:NilClass (NoMethodError)
2021-02-25T19:59:10.1785859Z    from /usr/local/bundle/gems/relaton-bib-1.7.1/lib/relaton_bib.rb:46:in `single_element_array'
2021-02-25T19:59:10.1787482Z    from /usr/local/bundle/gems/relaton-bib-1.7.1/lib/relaton_bib/bibliographic_item.rb:340:in `to_hash'
2021-02-25T19:59:10.1789029Z    from /usr/local/bundle/gems/relaton-bipm-1.7.0/lib/relaton_bipm/bipm_bibliographic_item.rb:69:in `to_hash'
2021-02-25T19:59:10.1790460Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/bibdata.rb:53:in `to_h'
2021-02-25T19:59:10.1791839Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/bibcollection.rb:122:in `map'
2021-02-25T19:59:10.1793302Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/bibcollection.rb:122:in `to_h'
2021-02-25T19:59:10.1794769Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/cli/xml_to_html_renderer.rb:120:in `document_items'
2021-02-25T19:59:10.1796400Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/cli/xml_to_html_renderer.rb:62:in `build_liquid_document'
2021-02-25T19:59:10.1797906Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/cli/xml_to_html_renderer.rb:18:in `render'
2021-02-25T19:59:10.1799343Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/cli/xml_to_html_renderer.rb:35:in `render'
2021-02-25T19:59:10.1800812Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/cli/base_convertor.rb:52:in `convert_to_html'
2021-02-25T19:59:10.1882494Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/cli/base_convertor.rb:22:in `to_html'
2021-02-25T19:59:10.1884368Z    from /usr/local/bundle/gems/relaton-cli-1.7.0/lib/relaton/cli/base_convertor.rb:43:in `to_html'
2021-02-25T19:59:10.1887440Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/lib/metanorma/cli/site_generator.rb:83:in `convert_to_html_page'
2021-02-25T19:59:10.1889186Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/lib/metanorma/cli/site_generator.rb:28:in `block in generate'
2021-02-25T19:59:10.1890878Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/lib/metanorma/cli/site_generator.rb:26:in `chdir'
2021-02-25T19:59:10.1892241Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/lib/metanorma/cli/site_generator.rb:26:in `generate'
2021-02-25T19:59:10.1893627Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/lib/metanorma/cli/site_generator.rb:19:in `generate'
2021-02-25T19:59:10.1894981Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/lib/metanorma/cli/commands/site.rb:23:in `generate'
2021-02-25T19:59:10.1896062Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
2021-02-25T19:59:10.1897445Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
2021-02-25T19:59:10.1898381Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
2021-02-25T19:59:10.1899244Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:116:in `invoke'
2021-02-25T19:59:10.1900127Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:243:in `block in subcommand'
2021-02-25T19:59:10.1900981Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
2021-02-25T19:59:10.1902023Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
2021-02-25T19:59:10.1902968Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
2021-02-25T19:59:10.1907028Z    from /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
2021-02-25T19:59:10.1908165Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/lib/metanorma/cli.rb:67:in `start'
2021-02-25T19:59:10.1909630Z    from /usr/local/bundle/bundler/gems/metanorma-cli-7b8381f1d1ff/exe/metanorma:20:in `<top (required)>'
2021-02-25T19:59:10.1911028Z    from /usr/local/bundle/bin/metanorma:23:in `load'
2021-02-25T19:59:10.1911721Z    from /usr/local/bundle/bin/metanorma:23:in `<main>'
ronaldtse commented 3 years ago

@andrew2net this is an urgent one. Can you please help? Thanks!

andrew2net commented 3 years ago

@CAMOBAP I'm trying to reproduce the error running make clean all in mn-samples-bip dir and got another error:

mkdir -p documents
BUILT_TARGET="sources/JCTLM/jctlm-ec-07.adoc"; \
    if [ "$BUILT_TARGET" = "" ] || [ "$BUILT_TARGET" = "null" ]; then \
        BUILT_TARGET=sources/JCTLM/jctlm-ec-07.xml; \
        echo "Running locally via bundle ..."; bundle exec metanorma -x xml "${BUILT_TARGET//xml/adoc}"; \
    else \
        if [ -f "$BUILT_TARGET" ] && [ "${BUILT_TARGET##*.}" == "xml" ]; then \
            cp "$BUILT_TARGET" sources/JCTLM/jctlm-ec-07.xml; \
        else \
            echo "Running locally via bundle ..."; bundle exec metanorma -x xml $BUILT_TARGET; \
            cp "${BUILT_TARGET//adoc/xml}" sources/JCTLM/jctlm-ec-07.xml; \
        fi \
    fi
Running locally via bundle ...
Metanorma XML Style Warning: (XML Line 000132): Hanging paragraph in clause
Metanorma XML Style Warning: (XML Line 000139): Hanging paragraph in clause
Metanorma XML Style Warning: (XML Line 000155): Hanging paragraph in clause
Metanorma XML Style Warning: (XML Line 000198): Hanging paragraph in clause
Syntax Valid!
cp: sources/JCTLM/jctlm-ec-07.xml and sources/JCTLM/jctlm-ec-07.xml are identical (not copied).
make: *** [sources/JCTLM/jctlm-ec-07.xml] Error 1
rm sources/JCTLM/jctlm-ec-07.xml

Do you have any suggestions why does it happen?

andrew2net commented 3 years ago

@CAMOBAP any way this error happens because the copyright element is made with from date equal nil. According to the bibliographic model the copyright's date, form is mandatory:

copyright =
  element copyright {
    from, to?, owner+, copyright_scope?
}

I can't see from the log which source document case the error.

CAMOBAP commented 3 years ago

@andrew2net according to logs from CI it's https://github.com/metanorma/mn-samples-bipm/blob/master/sources/monographie/bipm-7/document.adoc

andrew2net commented 3 years ago

@CAMOBAP I see there is :copyright-year: 2007 in the monographie/bipm-7/document.adoc, but the conversion into a bibmodel happens somewhere in metanorma. I'm trying to reproduce this issue to understand where the :copyright-year: becomes nil, but get another issue.

andrew2net commented 3 years ago

@CAMOBAP there isn't sources/monographie/bipm-7/document.adoc in the metanorma.yml file. Shouldn't it be there?

andrew2net commented 3 years ago

@CAMOBAP the issue is in the sources/JCTLM/jctlm_executive-15-03.adoc. It has an empty :copyright-year:.