xml2rfc icon indicating copy to clipboard operation
xml2rfc copied to clipboard

Missing file reported poorly for <sourcecode src=...>

Open jennifer-richards opened this issue 9 months ago • 0 comments

Describe the issue

Encountered in debugging https://github.com/ietf-tools/datatracker/issues/7405, a missing file referred to by the src attribute in a <sourcecode> element results in

/Users/jennifer/ietf/tmp/draft-ietf-sidrops-aspa-profile.xml(169): Error: Expected an <sourcecode> src= file at '/Users/jennifer/ietf/tmp/RPKI-ASPA-2023.asn', but no such file exists
Traceback (most recent call last):
  File "/Users/jennifer/Library/Python/3.11/bin/xml2rfc", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/jennifer/Library/Python/3.11/lib/python/site-packages/xml2rfc/run.py", line 727, in main
    xmlrfc.tree = prep.prep()
                  ^^^^^^^^^^^
  File "/Users/jennifer/Library/Python/3.11/lib/python/site-packages/xml2rfc/writers/preptool.py", line 220, in prep
    tree = self.dispatch(self.selectors)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jennifer/Library/Python/3.11/lib/python/site-packages/xml2rfc/writers/base.py", line 1931, in dispatch
    func(e, e.getparent())
  File "/Users/jennifer/Library/Python/3.11/lib/python/site-packages/xml2rfc/writers/preptool.py", line 1952, in element_sourcecode
    self.normalize_whitespace(e)
  File "/Users/jennifer/Library/Python/3.11/lib/python/site-packages/xml2rfc/writers/preptool.py", line 201, in normalize_whitespace
    lines = e.text.split('\n')
            ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'split'

There is a reasonable error at the top, but it's hidden before the stack trace and unhelpful details about a follow-on exception.

Really ought to end with "no such file exists" (and perhaps clean up the syntax of that error a bit)

Code of Conduct

jennifer-richards avatar May 14 '24 13:05 jennifer-richards