Project

Profile

Help

Maintenance. Planio will be undergoing a scheduled maintenance this weekend. Between Saturday, July 24 at 9:00 UTC and Sunday, July 25, 22:00 UTC your account might observe occasional downtimes which may last up to several minutes in some cases.

Issue #8954

Using form data doesn't set labels

Added by daviddavis about 1 month ago. Updated 11 days ago.

Status:
MODIFIED
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 100
Quarter:

Description

When setting pulp_labels using a request that sends form data, pulp_labels aren't getting set:

$ http --form -p b POST :/pulp/api/v3/remotes/file/file/ name=$RANDOM pulp_labels={"environment":"dev"} url='http://test'
{
    "ca_cert": null,
    "client_cert": null,
    "connect_timeout": null,
    "download_concurrency": null,
    "headers": null,
    "max_retries": null,
    "name": "11512",
    "policy": "immediate",
    "proxy_url": null,
    "pulp_created": "2021-06-23T13:08:15.205770Z",
    "pulp_href": "/pulp/api/v3/remotes/file/file/9882755c-adf5-472f-ad13-b0c9728d1eb2/",
    "pulp_labels": {},
    "pulp_last_updated": "2021-06-23T13:08:15.205796Z",
    "rate_limit": null,
    "sock_connect_timeout": null,
    "sock_read_timeout": null,
    "tls_validation": false,
    "total_timeout": null,
    "url": "http://test"
}

This works though:

http -p b POST :/pulp/api/v3/remotes/file/file/ name=$RANDOM pulp_labels:="{\"environment\":\"dev\"}" url='http://test'

Not sure what the difference is. At the very least, we should probably be raising an error if the format is incorrect.


Related issues

Related to Pulp - Backport #9058: Backport 8954 "using form data doesn't set labels" to 3.14.zCLOSED - CURRENTRELEASE

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

Associated revisions

Revision 3bc707ad View on GitHub
Added by Lubos Mjachky 12 days ago

Replace DictField with JSONField

closes #8954

History

#1 Updated by daviddavis about 1 month ago

  • Description updated (diff)

#2 Updated by dkliban@redhat.com 25 days ago

  • Triaged changed from No to Yes
  • Sprint set to Sprint 99

#3 Updated by rchan 22 days ago

  • Sprint changed from Sprint 99 to Sprint 100

#4 Updated by lmjachky 17 days ago

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

#5 Updated by lmjachky 15 days ago

It looks like rest_framework does not support dictionary form input (https://github.com/encode/django-rest-framework/blob/71e6c30034a1dd35a39ca74f86c371713e762c79/rest_framework/templates/rest_framework/inline/dict_field.html#L8) in the web UI. Furthermore, once the framework determines that a user passed data via an HTML form, it still tries to parse the data by searching for a regex match (https://github.com/encode/django-rest-framework/blob/71e6c30034a1dd35a39ca74f86c371713e762c79/rest_framework/utils/html.py#L69-L95). But, this approach will never find a match for pulp_labels because the method searches for keys like pulp_labels.xyz, in our case pulp_labels.environment. Such a key is considered always invalid:

{
    "pulp_labels.environment": [
        "Unexpected field"
    ]
}

The solution is to replace DictField (https://github.com/pulp/pulpcore/blob/3ca47373e4a33965da362e76bc269640f8dc6925/pulpcore/app/serializers/fields.py#L380) with JSONField.

#6 Updated by pulpbot 15 days ago

  • Status changed from ASSIGNED to POST

#7 Updated by dalley 15 days ago

  • Related to Backport #9058: Backport 8954 "using form data doesn't set labels" to 3.14.z added

#8 Updated by dalley 15 days ago

  • Sprint/Milestone set to 3.14.2

#9 Updated by Anonymous 12 days ago

  • Status changed from POST to MODIFIED

#10 Updated by ipanova@redhat.com 11 days ago

  • Sprint/Milestone changed from 3.14.2 to 3.15.0

Please register to edit this issue

Also available in: Atom PDF