Project

Profile

Help

Issue #4722

closed

Using the "fields=" feature has strange behavior with "created_resources"

Added by dalley over 5 years ago. Updated about 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
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

Related to RPM Support - Test #5180: Test scenario for filtering fields with created_resourcesCLOSED - COMPLETElmjachkyActions
Actions #1

Updated by amacdona@redhat.com over 5 years ago

  • Sprint/Milestone set to 3.0.0
  • Triaged changed from No to Yes
Actions #2

Updated by daviddavis over 5 years ago

  • Groomed changed from No to Yes
  • Sprint Candidate changed from No to Yes
Actions #3

Updated by ttereshc over 5 years ago

  • Sprint set to Sprint 55
Actions #4

Updated by dkliban@redhat.com over 5 years ago

  • Sprint changed from Sprint 55 to Sprint 56
Actions #5

Updated by lmjachky over 5 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to lmjachky

Added by Lubos Mjachky over 5 years ago

Revision ac75012b | View on GitHub

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

Actions #6

Updated by lmjachky over 5 years ago

  • Status changed from ASSIGNED to POST
Actions #7

Updated by Anonymous over 5 years ago

  • Status changed from POST to MODIFIED
Actions #8

Updated by kersom over 5 years ago

  • Related to Test #5180: Test scenario for filtering fields with created_resources added
Actions #9

Updated by bmbouter about 5 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF