Issue #9019
closedA variable referenced before assignment while reading repomd
Description
peter823:
I had a 403 response. It's about epel for centos 8. I took the baseurl from the epel.repo file (https://download.fedoraproject.org/pub/epel/8/Everything/x86_64/). If I open the link in the browser it redirects to another url (I think based on location). I also tried to sync with that url, but it leads to the same error.
I use the API. I start with http... :/repo_href/sync/ remote=<remote_href> then it gives me a tasks href. I open that and I just see this error.
Traceback:
{
"child_tasks": [],
"created_resources": [],
"error": {
"description": "local variable 'result' referenced before assignment",
"traceback": " File \"/var/lib/pulp/pulpvenv/lib64/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py\", line 266, in _perform_task\n result = func(*args, **kwargs)\n File \"/var/lib/pulp/pulpvenv/lib64/python3.6/site-packages/pulp_rpm/app/tasks/synchronizing.py\", line 338, in synchronize\n remote_url = fetch_remote_url(remote)\n File \"/var/lib/pulp/pulpvenv/lib64/python3.6/site-packages/pulp_rpm/app/tasks/synchronizing.py\", line 230, in fetch_remote_url\n if get_repomd_file(remote, remote_url):\n File \"/var/lib/pulp/pulpvenv/lib64/python3.6/site-packages/pulp_rpm/app/tasks/synchronizing.py\", line 199, in get_repomd_file\n return result\n"
},
"finished_at": "2021-07-06T08:36:59.760599Z",
"logging_cid": "76940f8873324f75baf986eed2aebd08",
"name": "pulp_rpm.app.tasks.synchronizing.synchronize",
"parent_task": null,
"progress_reports": [],
"pulp_created": "2021-07-06T08:36:59.159836Z",
"pulp_href": "/pulp/api/v3/tasks/9244515c-a580-430d-b899-51062d19cd83/",
"reserved_resources_record": [
"/pulp/api/v3/remotes/rpm/rpm/d9239766-b60d-4693-bc93-2dcf246a5db1/",
"/pulp/api/v3/repositories/rpm/rpm/d0ac1405-12a5-466b-b1cd-7d30593f00c0/"
],
"started_at": "2021-07-06T08:36:59.299450Z",
"state": "failed",
"task_group": null,
"worker": "/pulp/api/v3/workers/971399c7-92d3-4109-a8f4-7be89248ce04/"
}
The problem is that we do not consider any other HTTP status codes except for 404. When an exception is raised with a different HTTP status code, we read yet unassigned local variable result
(https://github.com/pulp/pulp_rpm/blob/440155ba24c296c982c329e76cb3768c0bac53e9/pulp_rpm/app/tasks/synchronizing.py#L197-L205).
Related issues