Issue #3556
closedInvalid URL when trying to sync with repository url with no dot in hostname
Description
Looks like there are problems around using a url sometimes that has a hostname with no dot (".").
$ http POST $IMPORTER_HREF'sync/' repository=http://pulp3:8000/api/v3/repositories/
{
"repository": [
"Enter a valid URL."
]
}
This is might be related to https://pulp.plan.io/issues/3476. More info: https://code.djangoproject.com/ticket/25418
Related issues
Updated by daviddavis over 6 years ago
- Subject changed from Pulp doesn't seem to like hostnames without "." to Invalid URL when trying to sync with repository url with no dot in hostname
Updated by dalley over 6 years ago
- Triaged changed from No to Yes
- Tags Pulp 3 added
Updated by dalley over 6 years ago
Are you sure this is a real issue? The HREF you're providing is the base repository endpoint, not a specific repository. I wouldn't expect that to work...
edit: I tested it, and I see what you're saying
[vagrant@pulp3 ~]$ echo $REPO_HREF
http://localhost:8000/api/v3/repositories/e7bd294f-4a5f-45ec-a582-534a8f029055/
[vagrant@pulp3 ~]$ http POST $REMOTE_HREF'sync/' repository=http://pulp3:8000/api/v3/repositories/e7bd294f-4a5f-45ec-a582-534a8f029055/
HTTP/1.1 400 Bad Request
Allow: POST, OPTIONS
Content-Type: application/json
Date: Sun, 15 Apr 2018 04:13:09 GMT
Server: WSGIServer/0.2 CPython/3.6.2
Vary: Accept
{
"repository": [
"Enter a valid URL."
]
}
Although I don't understand why specifying a non-repository is considered valid. It probably works ONLY because there is only one repository in existence during testing.
[vagrant@pulp3 ~]$ http POST $REMOTE_HREF'sync/' repository=http://localhost:8000/api/v3/repositories/
HTTP/1.1 202 Accepted
Allow: POST, OPTIONS
Content-Type: application/json
Date: Sun, 15 Apr 2018 04:15:28 GMT
Server: WSGIServer/0.2 CPython/3.6.2
Vary: Accept
[
{
"_href": "http://localhost:8000/api/v3/tasks/c4ddafe1-7f3f-4695-9557-5ae96c8ce59e/",
"task_id": "c4ddafe1-7f3f-4695-9557-5ae96c8ce59e"
}
]
edit: It totally blows up if you have 2 repositories
Internal Server Error: /api/v3/remotes/file/24ce2926-c3a5-43b1-85d9-e01408c54568/sync/
Traceback (most recent call last):
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/rest_framework/viewsets.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/rest_framework/views.py", line 483, in dispatch
response = self.handle_exception(exc)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/rest_framework/views.py", line 443, in handle_exception self.raise_uncaught_exception(exc)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/rest_framework/views.py", line 480, in dispatch response = handler(request, *args, **kwargs)
File "/home/vagrant/devel/pulp_file/pulp_file/app/viewsets.py", line 104, in sync repository = self.get_resource(repository_uri, Repository)
File "/home/vagrant/devel/pulp/pulpcore/pulpcore/app/viewsets/base.py", line 136, in get_resource return model.objects.get(**kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/vagrant/.virtualenvs/pulp/lib64/python3.6/site-packages/django/db/models/query.py", line 407, in get
(self.model._meta.object_name, num)
pulpcore.app.models.repository.MultipleObjectsReturned: get() returned more than one Repository -- it returned 2!
This is a separate issue though. I'll file it. edit: https://pulp.plan.io/issues/3567
Updated by daviddavis over 6 years ago
- Sprint set to Sprint 35
- Tags Pulp 3 MVP added
Talked with folks on IRC and decided we should try to fix this before the beta if possible.
Updated by amacdona@redhat.com over 6 years ago
I encountered a similar error, but I have a dot in my hostname:
~/3/devel ❯ http POST http://dev.pulp3:8000/api/v3/remotes/file/46c27193-16a8-4111-96be-c14af9016170/sync/ repository=http://dev.pulp3:8000/api/v3/repositories/2ad9c51b-f7af-4cfe-a978-523f1b54c6f2/ 3.0-dev
HTTP/1.0 400 Bad Request
Allow: POST, OPTIONS
Content-Length: 37
Content-Type: application/json
Date: Thu, 19 Apr 2018 14:25:05 GMT
Server: WSGIServer/0.2 CPython/3.6.4
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
{
"repository": [
"Enter a valid URL."
]
}
Updated by amacdona@redhat.com over 6 years ago
- Status changed from NEW to POST
Updated by amacdona@redhat.com over 6 years ago
- Assignee set to amacdona@redhat.com
The solution doesn't have anything to do with hostnames. It switches the serializer to use the HyperlinkedRelatedField which validates the urls in the same way that the model serializers validate repository and repository_version urls.
Added by amacdona@redhat.com over 6 years ago
Updated by amacdona@redhat.com over 6 years ago
- Status changed from POST to MODIFIED
Applied in changeset pulp_file:607e4336259d1f7b6217a2548fc989d6d566c6b2.
Updated by kersom about 5 years ago
- Related to Test #5653: Test invalid URL when trying to sync with repository url with no dot in hostname added
Updated by bmbouter about 5 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Use HyperlinkedRelatedField to validate relations
https://pulp.plan.io/issues/3556 fixes #3556