Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classic arXiv API error handling #257

Closed
mhl10 opened this issue Jan 10, 2020 · 3 comments
Closed

Classic arXiv API error handling #257

mhl10 opened this issue Jan 10, 2020 · 3 comments
Assignees
Labels

Comments

@mhl10
Copy link
Contributor

mhl10 commented Jan 10, 2020

Ensure that the classic API returns the correct errors as Atom feeds as described in the documentation.

@mhl10 mhl10 added the bug label Jan 10, 2020
@mhl10 mhl10 assigned mhl10 and unassigned mhl10 Jan 10, 2020
@mhl10 mhl10 changed the title classic API error handling Classic API error handling Jan 10, 2020
@mhl10 mhl10 changed the title Classic API error handling Classic arXiv API error handling Jan 10, 2020
@mhl10 mhl10 assigned mhl10 and alefnula and unassigned mhl10 Jan 10, 2020
@alefnula
Copy link
Collaborator

Report

@mhl10

Documentation: https://arxiv.org/help/api/user-manual#errors

start must be an integer

When start is not an integer it defaults to 0 and doesn't throw an error.

Old api returns 400 BAD REQUEST

<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom">
  <link href="http://arxiv.org/api/query?search_query%3Dall%3Aelectron%26id_list%3D%26start%3Dfoo" rel="self" type="application/atom+xml"/>
  <title type="html">ArXiv Query: search_query=all:electron&amp;id_list=&amp;start=foo</title>
  <id>http://arxiv.org/api/UWzh+Yg7RhgQkCAe0CazZj6gCc4</id>
  <updated>2020-01-17T00:00:00-05:00</updated>
  <opensearch:totalResults
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:totalResults>
  <opensearch:startIndex
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">0
  </opensearch:startIndex>
  <opensearch:itemsPerPage
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:itemsPerPage>
  <entry>
    <id>http://arxiv.org/api/errors#start_must_be_an_integer</id>
    <title>Error</title>
    <summary>start must be an integer</summary>
    <updated>2020-01-17T00:00:00-05:00</updated>
    <link href="http://arxiv.org/api/errors#start_must_be_an_integer" rel="alternate" type="text/html"/>
    <author>
      <name>arXiv api core</name>
    </author>
  </entry>
</feed>

start must be >= 0

If start < 0 the classic api throws 500 INTERNAL SERVER ERROR

Old api returns 400 BAD REQUEST

<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom">
  <link href="http://arxiv.org/api/query?search_query%3Dall%3Aelectron%26id_list%3D%26start%3D-1" rel="self" type="application/atom+xml"/>
  <title type="html">ArXiv Query: search_query=all:electron&amp;id_list=&amp;start=-1</title>
  <id>http://arxiv.org/api/YkFYqqDq37HTbtT4J7COVsgCsV0</id>
  <updated>2020-01-17T00:00:00-05:00</updated>
  <opensearch:totalResults
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:totalResults>
  <opensearch:startIndex
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">0
  </opensearch:startIndex>
  <opensearch:itemsPerPage
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:itemsPerPage>
  <entry>
    <id>http://arxiv.org/api/errors#start_must_be_non-negative</id>
    <title>Error</title>
    <summary>start must be non-negative</summary>
    <updated>2020-01-17T00:00:00-05:00</updated>
    <link href="http://arxiv.org/api/errors#start_must_be_non-negative" rel="alternate" type="text/html"/>
    <author>
      <name>arXiv api core</name>
    </author>
  </entry>
</feed>

max_results must be an integer

When start is not an integer it defaults to 50 and doesn't throw an error.

Old api returns 400 BAD REQUEST

<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom">
  <link href="http://arxiv.org/api/query?search_query%3Dall%3Aelectron%26id_list%3D%26max_results%3Dfoo" rel="self" type="application/atom+xml"/>
  <title type="html">ArXiv Query: search_query=all:electron&amp;id_list=&amp;max_results=foo</title>
  <id>http://arxiv.org/api/1NtmSDRzscqheSLNkuVpxrq9S1Q</id>
  <updated>2020-01-17T00:00:00-05:00</updated>
  <opensearch:totalResults
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:totalResults>
  <opensearch:startIndex
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">0
  </opensearch:startIndex>
  <opensearch:itemsPerPage
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:itemsPerPage>
  <entry>
    <id>http://arxiv.org/api/errors#max_results_must_be_an_integer</id>
    <title>Error</title>
    <summary>max_results must be an integer</summary>
    <updated>2020-01-17T00:00:00-05:00</updated>
    <link href="http://arxiv.org/api/errors#max_results_must_be_an_integer" rel="alternate" type="text/html"/>
    <author>
      <name>arXiv api core</name>
    </author>
  </entry>
</feed>

max_results must be >= 0

  1. If max_results < 0 the classic api throws 500 INTERNAL SERVER ERROR
  2. If max_results == 0 the classic api throws 500 INTERNAL SERVER ERROR (ZeroDivisionError)

Old api doesn't throw an error for max_results=0 it just returns 200 OK with an empty set, for < 0 it returns 400 BAD REQUEST

<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom">
  <link href="http://arxiv.org/api/query?search_query%3Dall%3Aelectron%26id_list%3D%26max_results%3D-3" rel="self" type="application/atom+xml"/>
  <title type="html">ArXiv Query: search_query=all:electron&amp;id_list=&amp;max_results=-3</title>
  <id>http://arxiv.org/api//lp/Kfcyl4Qm57On7NSU2k7Y6qk</id>
  <updated>2020-01-17T00:00:00-05:00</updated>
  <opensearch:totalResults
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:totalResults>
  <opensearch:startIndex
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">0
  </opensearch:startIndex>
  <opensearch:itemsPerPage
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:itemsPerPage>
  <entry>
    <id>http://arxiv.org/api/errors#max_results_must_be_non-negative</id>
    <title>Error</title>
    <summary>max_results must be non-negative</summary>
    <updated>2020-01-17T00:00:00-05:00</updated>
    <link href="http://arxiv.org/api/errors#max_results_must_be_non-negative" rel="alternate" type="text/html"/>
    <author>
      <name>arXiv api core</name>
    </author>
  </entry>
</feed>

malformed id

If id_list parameter is malformed the classic api returns 200 OK with empty result set.

Old api returns 400 BAD REQUEST

<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom">
  <link href="http://arxiv.org/api/query?search_query%3D%26id_list%3Dcond%E2%80%94mat%2F0709123" rel="self" type="application/atom+xml"/>
  <title type="html">ArXiv Query: search_query=&amp;id_list=cond—mat/0709123</title>
  <id>http://arxiv.org/api/R2LV9Qg5vr0tr7Xo15km9/vtX0g</id>
  <updated>2020-01-17T00:00:00-05:00</updated>
  <opensearch:totalResults
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:totalResults>
  <opensearch:startIndex
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">0
  </opensearch:startIndex>
  <opensearch:itemsPerPage
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">1
  </opensearch:itemsPerPage>
  <entry>
    <id>http://arxiv.org/api/errors#incorrect_id_format_for_cond—mat/0709123</id>
    <title>Error</title>
    <summary>incorrect id format for cond—mat/0709123</summary>
    <updated>2020-01-17T00:00:00-05:00</updated>
    <link href="http://arxiv.org/api/errors#incorrect_id_format_for_cond—mat/0709123" rel="alternate" type="text/html"/>
    <author>
      <name>arXiv api core</name>
    </author>
  </entry>
</feed>

@alefnula
Copy link
Collaborator

alefnula commented Jan 17, 2020

@mhl10 Am I allowed to change the code and fix these differences?

If yes is there already an error handling module implemented? If there is can you point me to it in the repository?

Thank you!

@mhl10
Copy link
Contributor Author

mhl10 commented Jan 17, 2020

@alefnula thanks for this comprehensive report! Yes, please feel free to make changes; I'd suggest a separate branch (we follow the GitFlow branching model). Unfortunately there is currently no error handling module implemented for the classic API.

mhl10 added a commit that referenced this issue Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants