chaoss / chaoss/grimoirelab-perceval

[BugzillaREST] requests.exceptions.HTTPError: 400 Client Error: Bad Request for url

Open
#875 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
324
Forks
187
PR merge metrics
No merged PRs in 30d

Description

System information
  • Python 3.12.8
  • perceval==1.3.1
Issue description

When downloading Bugzilla data, the request fails with the error:

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://bugzilla.mozilla.org/rest/bug?last_change_time=2023-02-09T03%3A28%3A55Z&limit=25&order=changeddate&include_fields=_all&offset=25&api_key=<your-bugzilla-api-key>

When executing the URL in the browser, it returns an error as well, however if you increase the offset by amount x (in this example offset=40), it works again.

Steps to reproduce the issue
from perceval.backends.core.bugzillarest import BugzillaREST
from datetime import datetime

if __name__ == '__main__':
    init_args={
        'url': 'https://bugzilla.mozilla.org',
        'api_key': '<your-bugzilla-api-key>',
        'max_bugs': 25,
    }

    fetch_args={
        'from_date': datetime(2023, 1, 1)
    }

    backend = BugzillaREST(**init_args)
    iterator = backend.fetch(**fetch_args)
    for i, issue in enumerate(iterator):
        print('i')
What's the expected result?
  • The fetch function should increment offset by amount x until the request returns data again.
  • Or take offset as initial kwarg in the fetch function, so the users can skip it themselves.
What's the actual result?
  • The fetch function stops with an errro

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in perceval/backends/core/bugzillarest.py at BugzillaREST.fetch and reproduce the failing request with the issue's Python example. Trace how the offset is passed to Bugzilla and determine how the requested offset behavior should be handled. Done means fetching continues past a 400 response or provides the requested way to skip the problematic offset, with the behavior verified against the reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.