Project

Profile

Help

Issue #1584

closed

400 error when trying to kick off applicability regeneration

Added by dkliban@redhat.com about 8 years ago. Updated about 5 years ago.

Status:
CLOSED - NOTABUG
Priority:
Normal
Assignee:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
2.8.0
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

My criteria.json file looks like this:

{
 "repo_criteria": {
 "filters":{ "id": {"$in":["ideate"]}}
 }
}
$ http --json --verify no --auth admin:admin POST "https://localhost/pulp/api/v2/repositories/actions/content/regenerate_applicability/" < criteria.json 
HTTP/1.1 400 BAD REQUEST
Connection: close
Content-Encoding: utf-8
Content-Length: 374
Content-Type: application/json; charset=utf-8
Date: Tue, 26 Jan 2016 14:28:25 GMT
Server: Apache/2.4.18 (Fedora) OpenSSL/1.0.2e-fips mod_wsgi/4.4.8 Python/2.7.10

{
    "_href": "/pulp/api/v2/repositories/actions/content/regenerate_applicability/", 
    "args": [], 
    "error": {
        "code": "PLP1015", 
        "data": {
            "data_type": "dict"
        }, 
        "description": "The JSON data must be of type 'dict'.", 
        "sub_errors": []
    }, 
    "error_message": "The JSON data must be of type 'dict'.", 
    "exception": null, 
    "http_request_method": "POST", 
    "http_status": 400, 
    "traceback": null
}

The exception is being raised here[0]. This is a regression as result of this[1] commit.

[0] https://github.com/pulp/pulp/blob/master/server/pulp/server/webservices/views/util.py#L125
[1] https://github.com/pulp/pulp/commit/75af2dd1113d47a282911c6a88b47a7f7d193dde

Actions #1

Updated by dkliban@redhat.com about 8 years ago

Interestingly enough the following command does work:

http --verify no --auth admin:admin POST "https://localhost/pulp/api/v2/repositories/actions/content/regenerate_applicability/" < criteria.json

The difference is that --json is not specified here. According to documentation[0] for httpie, this adds an Accepts header to the request.

[0] https://github.com/jkbrzt/httpie#json

Actions #2

Updated by ttereshc about 8 years ago

Interesting... I was trying to figure out why curl works for me and your command is not.

When --json is specified, the request body looks like this, with too much escapes:

\"{\\n \\\"repo_criteria\\\": {\\n \\\"filters\\\":{ \\\"id\\\": {\\\"$in\\\":[\\\"ideate\\\"]}}\\n   }\\n}\\n\"

so after parsing it becomes just a string and "The JSON data must be of type 'dict'." is raised.

Actions #3

Updated by bmbouter about 8 years ago

It would appear that --json is causing additional escaping to be used.

--json sets both the Accept header but more importantly the Content-Type header, which I believe is the header of interest here.

If you want to use a file to provide the body contents, and have the Content-Type header set correctly by the file extension you are submitting you could do:

http --verify no --auth admin:admin POST "https://localhost/pulp/api/v2/repositories/actions/content/regenerate_applicability/" @criteria.json

This is documented here[0].

[0]: https://github.com/jkbrzt/httpie#body-data-from-a-filename

Actions #4

Updated by ttereshc about 8 years ago

  • Status changed from NEW to CLOSED - NOTABUG

It looks like this issue is filed https://github.com/jkbrzt/httpie/issues/379

Actions #5

Updated by bmbouter about 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF