Project

Profile

Help

Issue #3556

Invalid URL when trying to sync with repository url with no dot in hostname

Added by daviddavis about 2 years ago. Updated 6 months ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
Start date:
Due date:
Severity:
2. Medium
Version:
Platform Release:
Blocks Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
QA Contact:
Complexity:
Smash Test:
Sprint:
Sprint 35

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

Related to Pulp - Test #5653: Test invalid URL when trying to sync with repository url with no dot in hostname NEW Actions

Associated revisions

Revision 607e4336 View on GitHub
Added by amacdona@redhat.com about 2 years ago

Use HyperlinkedRelatedField to validate relations

https://pulp.plan.io/issues/3556 fixes #3556

History

#1 Updated by daviddavis about 2 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

#2 Updated by dalley about 2 years ago

  • Triaged changed from No to Yes
  • Tags Pulp 3 added

#3 Updated by dalley about 2 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

#4 Updated by daviddavis about 2 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.

#5 Updated by amacdona@redhat.com about 2 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."
    ]
}

#6 Updated by amacdona@redhat.com about 2 years ago

  • Status changed from NEW to POST

#7 Updated by amacdona@redhat.com about 2 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.

#8 Updated by amacdona@redhat.com about 2 years ago

  • Status changed from POST to MODIFIED

#9 Updated by daviddavis about 2 years ago

  • Smash Test set to 983

#10 Updated by daviddavis about 1 year ago

  • Sprint/Milestone set to 3.0.0

#11 Updated by bmbouter about 1 year ago

  • Tags deleted (Pulp 3, Pulp 3 MVP)

#12 Updated by kersom 7 months ago

  • Related to Test #5653: Test invalid URL when trying to sync with repository url with no dot in hostname added

#13 Updated by bmbouter 6 months ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Please register to edit this issue

Also available in: Atom PDF