Project

Profile

Help

Issue #4722

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

Added by dalley 6 months ago. Updated 3 months ago.

Status:
MODIFIED
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Severity:
2. Medium
Version:
Platform Release:
Blocks Release:
OS:
Backwards Incompatible:
No
Triaged:
Yes
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
QA Contact:
Complexity:
Smash Test:
Verified:
No
Verification Required:
No
Sprint:
Sprint 56

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_resources CLOSED - COMPLETE Actions

Associated revisions

Revision ac75012b View on GitHub
Added by Lubos Mjachky 3 months ago

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

History

#1 Updated by amacdona@redhat.com 6 months ago

  • Sprint/Milestone set to 3.0
  • Triaged changed from No to Yes

#2 Updated by daviddavis 4 months ago

  • Groomed changed from No to Yes
  • Sprint Candidate changed from No to Yes

#3 Updated by ttereshc 4 months ago

  • Sprint set to Sprint 55

#4 Updated by dkliban@redhat.com 3 months ago

  • Sprint changed from Sprint 55 to Sprint 56

#5 Updated by lmjachky 3 months ago

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

#6 Updated by lmjachky 3 months ago

  • Status changed from ASSIGNED to POST

#7 Updated by Anonymous 3 months ago

  • Status changed from POST to MODIFIED

#8 Updated by kersom 2 months ago

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

Please register to edit this issue

Also available in: Atom PDF