Skip to content

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

@jennifer-richards

Description

@jennifer-richards

Describe the issue

Encountered in debugging ietf-tools/datatracker#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions