Project

Profile

Help

Issue #1584

400 error when trying to kick off applicability regeneration

Added by dkliban@redhat.com almost 5 years ago. Updated almost 2 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

History

#1 Updated by dkliban@redhat.com almost 5 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

#2 Updated by ttereshc almost 5 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.

#3 Updated by bmbouter almost 5 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

#4 Updated by ttereshc almost 5 years ago

  • Status changed from NEW to CLOSED - NOTABUG

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

#5 Updated by bmbouter almost 2 years ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF