Project

Profile

Help

Issue #412

closed

Association of importer with invalid importer type should return 400

Added by ipanova@redhat.com about 9 years ago. Updated almost 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
Platform Release:
2.6.1
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

Description of problem:
Association of importer with invalid importer type should return 404, and not a call report that later will fail.

$ curl H "Accept: application/json" -X POST -k -u admin:admin -d '{"importer_type_id": "yum_importer1", "importer_config":{}}' 'https://example.com/pulp/api/v2/repositories/m1/importers/' | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 231 100 172 100 59 126 43 0:00:01 0:00:01 -
:--:-- 126
{
"error": null,
"result": null,
"spawned_tasks": [
{
"_href": "/pulp/api/v2/tasks/0f3e8cbd-ea84-445a-9a1d-b29f6d11e922/",
"task_id": "0f3e8cbd-ea84-445a-9a1d-b29f6d11e922"
}
]
}

$ curl H "Accept: application/json" -X GET -k -u admin:admin 'https://example.com/pulp/api/v2/tasks/0f3e8cbd-ea84-445a-9a1d-b29f6d11e922/' | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1277 100 1277 0 0 1530 0 -
:--:-- --:--:-- --:--:-- 1529
{
"_href": "/pulp/api/v2/tasks/0f3e8cbd-ea84-445a-9a1d-b29f6d11e922/",
"_id": {
"$oid": "533d6e1e3965e4939dfae505"
},
"_ns": "task_status",
"error": {
"code": "PLP0015",
"data": {
"properties": "['importer_type_id']",
"property_names": [
"importer_type_id"
]
},
"description": "Invalid properties: ['importer_type_id']",
"sub_errors": []
},
"finish_time": 1396534814,
"queue": "",
"start_time": 1396534814,
"state": "error",
"tags": [
"pulp:repository:m1",
"pulp:action:add_importer"
],
"task_id": "0f3e8cbd-ea84-445a-9a1d-b29f6d11e922",
"traceback": "Traceback (most recent call last):\n File \"/usr/lib/python2.7/site-packages/celery/app/trace.py\", line 238, in trace_task\n R = retval = fun(*args, **kwargs)\n File \"/usr/lib/python2.7/site-packages/pulp/server/async/tasks.py\", line 369, in call\n return super(Task, self).__call__(*args, **kwargs)\n File \"/usr/lib/python2.7/site-packages/celery/app/trace.py\", line 416, in protected_call\n return self.run(*args, **kwargs)\n File \"/usr/lib/python2.7/site-packages/pulp/server/managers/repo/importer.py\", line 117, in set_importer\n raise InvalidValue(['importer_type_id'])\nInvalidValue: Invalid properties: ['importer_type_id']\n"
}

Version-Release number of selected component (if applicable):
pulp-server-2.4.0-0.3.alpha.git.13.3215df6.fc20.noarch

How reproducible:
always

Steps to Reproduce:
1. create repo
2. associate importer with invalid importer type
3.

Actual results:
Association of importer with invalid importer type returns 202(a task that fails)

Expected results:
Association of importer with invalid importer type returns 404

Additional info:

+ This bug was cloned from Bugzilla Bug #1084064 +

Actions #2

Updated by ipanova@redhat.com about 9 years ago

Sorry, got confused - in this case it should return 400
Taken from docs:
"400 - if one or more of the required parameters is missing, the importer type ID refers to a non-existent importer, or the importer indicates the supplied configuration is invalid"

+ This comment was cloned from Bugzilla #1084064 comment 2 +

Actions #3

Updated by jcline@redhat.com about 9 years ago

https://github.com/pulp/pulp/pull/1423

This PR fixes several issues:

1. curl -H "Accept: application/json" -X POST -k -u admin:admin -d '{"importer_type_id": "bees", "importer_config":{}}' 'https://localhost/pulp/api/v2/repositories/notarepo/importers/' | python -m json.tool

should now result in a 404 (assuming you don't have a repo called notarepo).

2. curl -H "Accept: application/json" -X POST -k -u admin:admin -d '{"importer_type_id": "bees", "importer_config":{}}' 'https://localhost/pulp/api/v2/repositories/beads/importers/' | python -m json.tool

should result in a 400 (assuming you do have a repository called beads and there isn't an importer with the id bees).

3. curl -H "Accept: application/json" -X POST -k -u admin:admin -d '{"importer_type_id": "yum_importer", "importer_config":{"max_speed": -2}}' 'https://localhost/pulp/api/v2/repositories/beads/importers/' | python -m json.tool

should result in a 400 assuming the yum importer is installed an a repo called beads exists.

Previously they all resulted in 202.

+ This comment was cloned from Bugzilla #1084064 comment 3 +

Actions #4

Updated by jcline@redhat.com about 9 years ago

This was merged into 2.6-dev, which I believe maps to 2.6.1 currently.

+ This comment was cloned from Bugzilla #1084064 comment 4 +

Actions #5

Updated by mkovacik@redhat.com about 9 years ago

Hi,

I've checked with pulp-server-2.6.0-0.5.beta.git.93.014a6ca.fc21.noarch and this seems fixed now --- is it expected in the beta build? If that's the case, I'll mark verified...

+ This comment was cloned from Bugzilla #1084064 comment 5 +

Actions #6

Updated by mkovacik@redhat.com about 9 years ago

pulled wrong pulp repo; status is OK; leaving on MODIFIED

+ This comment was cloned from Bugzilla #1084064 comment 6 +

Actions #7

Updated by bcourt about 9 years ago

  • Status changed from MODIFIED to 5
Actions #8

Updated by igulina@redhat.com about 9 years ago

  • Status changed from 5 to 6
  • Severity set to 1. Low

Reproduced on rpm -qa pulp-server
pulp-server-2.6.0-0.7.beta.el6.noarch

Verified on

rpm -qa pulp-server

pulp-server-2.6.1-0.2.beta.el6.noarch and

pulp-server-2.6.1-0.2.beta.fc20.noarch

1) >> curl H "Accept: application/json" -X POST -k -u admin:admin -d '{"importer_type_id": "bees", "importer_config":{}}' 'https://localhost/pulp/api/v2/repositories/notarepo/importers/' | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
115 411 102 411 0 50 1142 138 -
:--:-- --:--:-- --:--:-- 1719
{
"_href": "/pulp/api/v2/repositories/notarepo/importers/",
"error": {
"code": "PLP0009",
"data": {
"resources": {
"resource_id": "notarepo"
}
},
"description": "Missing resource(s): resource_id=notarepo",
"sub_errors": []
},
"error_message": "Missing resource(s): resource_id=notarepo",
"exception": null,
"http_request_method": "POST",
"http_status": 404,
"resources": {
"resource_id": "notarepo"
},
"traceback": null
}

2) >>pulp-admin repo list
--------------------------------------------------------------------
Repositories
--------------------------------------------------------------------

Id: gena
Display Name: gena
Description: None
Content Unit Counts:

curl -H "Accept: application/json" -X POST -k -u admin:admin -d '{"importer_type_id": "bees", "importer_config":{}}' 'https://localhost/pulp/api/v2/repositories/gena/importers/' | python -m json.tool

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
135 355 118 355 0 50 1048 147 --:--:-- --:--:-- --:--:-- 1871
{
"_href": "/pulp/api/v2/repositories/gena/importers/",
"args": [],
"error": {
"code": "PLP1008",
"data": {
"importer_type_id": "bees"
},
"description": "The importer type bees does not exist",
"sub_errors": []
},
"error_message": "The importer type bees does not exist",
"exception": null,
"http_request_method": "POST",
"http_status": 400,
"traceback": null
}

3) >> curl H "Accept: application/json" -X POST -k -u admin:admin -d '{"importer_type_id": "yum_importer", "importer_config":{"max_speed": -2}}' 'https://localhost/pulp/api/v2/repositories/gena/importers/' | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
136 471 117 471 0 73 1301 201 -
:--:-- --:--:-- --:--:-- 2235
{
"_href": "/pulp/api/v2/repositories/gena/importers/",
"args": [],
"error": {
"code": "PLP1000",
"data": {
"validation_errors": "Configuration errors:\nThe configuration parameter <max_speed> must be set to a positive numerical value, but is currently set to <-2.0>."
},
"description": "A validation error occurred.",
"sub_errors": []
},
"error_message": "A validation error occurred.",
"exception": null,
"http_request_method": "POST",
"http_status": 400,
"traceback": null
}

Actions #9

Updated by dkliban@redhat.com almost 9 years ago

  • Status changed from 6 to CLOSED - CURRENTRELEASE
Actions #11

Updated by bmbouter about 5 years ago

  • Tags Pulp 2 added
Actions #12

Updated by bmbouter almost 4 years ago

  • Category deleted (14)

We are removing the 'API' category per open floor discussion June 16, 2020.

Also available in: Atom PDF