Project

Profile

Help

Issue #2775

closed

pulp worker api uses reserved character @ in url route

Added by bizhang over 7 years ago. Updated over 5 years ago.

Status:
CLOSED - NOTABUG
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:
Quarter:

Description

Problem:

Currently Worker name is being used as the natural key, this is good because worker lookup urls are informative and expressive.
Worker name currently is {service_name}@{host}. This is also good and makes a lot of sense.
The issue is that reserved characters should not be allowed in url path variables..

Django urlquotes the generated url [0] however since @ is a reserved character that could show up in urls, django ignores it.

Passing in a prequoted worker name would not work since django would urlquote the %40

Potential Solutions:

1.) Create a new drf field and overwrite the get_url[1] function to take the full url django returns, and urlquote only the last path variable. To me this seems like a hack, but it would theoretically work. This allows us to keep @ as the delimiting character

2.) Use a different delimiter. Some proposed ones are .~-_

3.) Structure the lookup url path to nest host and service name /workers/{host}/{service}/ The issue with this approach is spelled out in https://pulp.plan.io/issues/2775?pn=1#note-9

4.) The easiest solution would be to, of course, switch to using UUID for the worker lookup_field. We would lose the expressiveness of using the natural key, but can keep the @ in the worker name

Or there might be some other solution that I'm not seeing

[0] https://github.com/django/django/blob/stable/1.8.x/django/utils/encoding.py#L210
[1] https://github.com/encode/django-rest-framework/blob/ee1a9fcef659d0a5885712575562acb71a502f21/rest_framework/relations.py#L300

Also available in: Atom PDF