Actions
Issue #4722
closedUsing the "fields=" feature has strange behavior with "created_resources"
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
Sprint:
Sprint 56
Quarter:
Description
Pulp has a features where you can give a list of field names when GET'ing an endpoint and it will return just those fields. This doesn't work with "created_resources"
(pulp) [vagrant@pulp3-source-fedora29 pulpcore]$ http GET :8000/pulp/api/v3/tasks/?fields=created_resources
HTTP/1.1 200 OK
Allow: GET, HEAD, OPTIONS
Connection: close
Content-Length: 252
Content-Type: application/json
Date: Sat, 20 Apr 2019 05:22:33 GMT
Server: gunicorn/19.9.0
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
{
"count": 5,
"next": null,
"previous": null,
"results": [
{
"created_resources": [
null
]
},
{
"created_resources": []
},
{
"created_resources": []
},
{
"created_resources": []
},
{
"created_resources": [
null
]
}
]
...unless you also ask for the "_href" field...
(pulp) [vagrant@pulp3-source-fedora29 pulpcore]$ http GET :8000/pulp/api/v3/tasks/?fields=created_resources,_href
HTTP/1.1 200 OK
Allow: GET, HEAD, OPTIONS
Connection: close
Content-Length: 1153
Content-Type: application/json
Date: Sat, 20 Apr 2019 05:28:37 GMT
Server: gunicorn/19.9.0
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
{
"count": 5,
"next": null,
"previous": null,
"results": [
{
"_href": "/pulp/api/v3/tasks/53f70631-2291-4504-872c-2b0273e77be6/",
"created_resources": [
"/pulp/api/v3/repositories/ba02a128-5dcd-4c95-bbd7-137b4717fcea/versions/3/"
]
},
{
"_href": "/pulp/api/v3/tasks/aed745a7-e6f1-41a6-abde-94eb1994c3ed/",
"created_resources": []
},
{
"_href": "/pulp/api/v3/tasks/2cef00bf-d413-411c-9e2b-62e12da35a21/",
"created_resources": []
},
{
"_href": "/pulp/api/v3/tasks/1d72663c-811f-4ec8-8069-bf1250d4cf56/",
"created_resources": []
},
{
"_href": "/pulp/api/v3/tasks/ef79f412-3521-4d10-9d75-62600916d1fa/",
"created_resources": [
"/pulp/api/v3/repositories/2cf65405-d4e0-43d2-8385-649eb314263c/versions/1/"
]
}
]
}
Related issues
Actions
Fetch all fields when initializing a serializer
When a user used _href within the fields selection, the serializer could fetch a correct value from _href. This commit removes a need to specify _href while filtering fields from the response.
When the data model will change, this may cause performance drawbacks due to serializing all fields of Task objects.
closes #4722 https://pulp.plan.io/issues/4722