Skip to content

arxiv.get_metadata doctest reports KeyError doi instead of the arXiv error #2805

Open

Description

@WolfgangFahl

✍️🤖 Agent/Nous: on behalf of @WolfgangFahl

In two CI runs on 2026-10-02 and 2026-10-03 (commit 1626b5e) the doctest of scholia.arxiv.get_metadata failed with

>>> metadata = get_metadata(1503.00759)
>>> metadata[doi] == 10.1109/JPROC.2015.2483592
UNEXPECTED EXCEPTION: KeyError(doi)

A rerun shortly afterwards passed. The arXiv API delivers arxiv:doi 10.1109/JPROC.2015.2483592 for 1503.00759 and feedparser 6.0.14 maps it to arxiv_doi, so the data and the parsing are fine.

The KeyError hides the real cause: on a non 200 status, a network error or any other exception get_metadata returns a dict with only the key error, so the doctest cannot show what arXiv answered. The broad except Exception also hides parsing errors.

Proposal:

  • the doctest shows the error together with the doi, e.g.
>>> metadata = get_metadata(1503.00759)
>>> metadata.get(error), metadata.get(doi)
(None, 10.1109/JPROC.2015.2483592)

Activity

  1. fnielsen commented on Oct 8, 2026

    @fnielsen
    Collaborator

    I suppose usual tests would set up a mock arXiv when testing, while we are testing directly at the real service - and this can for various reasons fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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