Skip to content

Uncaught exception on /xml endpoint #98

@ehenneken

Description

@ehenneken

Message before exception was generated:

attempting to resolve the reference=`They are, I find, contained in a paper of some length in vol. vi of " Taylor's Scientific Memoirs ", 1853, pp. 114--162.` in text mode now

Original reference data (in file with extension .jats.xml:

<ref id="CR1"><label>1</label><mixed-citation publication-type="other">They are, I find, contained in a paper of some length in vol. <bold>vi</bold> of "<italic>Taylor's Scientific Memoirs</italic>", 1853, pp. 114�~@~S162.</mixed-citation></ref>

From graylog

Traceback (most recent call last):
  File "/app/referencesrv/views.py", line 227, in xml_resolve
    resolved = str(solve_reference(Hypotheses(parsed_reference)))
  File "/app/referencesrv/resolver/solve.py", line 333, in solve_reference
    raise Incomplete("Not enough information to resolve the record.", str(ref))
referencesrv.resolver.common.Incomplete: ('Not enough information to resolve the record.', ', .   ')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/app/referencesrv/views.py", line 378, in xml_post
    results.append(xml_resolve(parsed_reference, returned_format))
  File "/app/referencesrv/views.py", line 244, in xml_resolve
    parsed_ref = text_parser(reference_str)
  File "/app/referencesrv/views.py", line 47, in text_parser
    return current_app.extensions['text_crf'].parse(reference)
  File "/app/referencesrv/parser/crf.py", line 626, in parse
    return self.reference(reference_str, words, labels)
  File "/app/referencesrv/parser/crf.py", line 312, in reference
    ref_dict['authors'] = self.originator_token.collect_tagged_tokens(words, labels)
  File "/app/referencesrv/parser/originator.py", line 393, in collect_tagged_tokens
    while name[-1] in [',', ' ']:
IndexError: list index out of range

The best way to solve this is to catch the underlying exception early on. Currently line 312 in crf.py can throw an exception that is not caught. So, one way to solve the problem at hand is to introduce a custom exception (for clarity). Something like

try:
    ref_dict['authors'] = self.originator_token.collect_tagged_tokens(words, labels)
except Exception as err:
    raise CollectTaggedTokensException(err)

and add this exception to line 259 in views.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions