Skip to content

Conversation

@jathanism
Copy link
Contributor

Fixes: #5977

This is a minor patch that makes the test in netbox.settings to correctly validate that RELEASE_CHECK_URL is a valid URL. I wasn't able to find a place where these settings are tested in the test suite, so I am providing some interactive Python shell output to illustrate the fix:

In [1]: from django.core.validators import URLValidator

In [2]: from django.core.exceptions import ImproperlyConfigured, ValidationError

In [3]: RELEASE_CHECK_URL = 'bogus url'

In [4]: if RELEASE_CHECK_URL:
   ...:     validator = URLValidator(
   ...:         message=(
   ...:             "RELEASE_CHECK_URL must be a valid API URL. Example: "
   ...:             "https://api.github.com/repos/netbox-community/netbox"
   ...:         )
   ...:     )
   ...:     try:
   ...:         validator(RELEASE_CHECK_URL)
   ...:     except ValidationError as err:
   ...:         raise ImproperlyConfigured(str(err))
   ...:
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
<ipython-input-4-8bf07c825907> in <module>
      8     try:
----> 9         validator(RELEASE_CHECK_URL)
     10     except ValidationError as err:

~/Library/Caches/pypoetry/virtualenvs/nautobot-b2ttWva6-py3.8/lib/python3.8/site-packages/django/core/validators.py in __call__(self, value)
    104         if scheme not in self.schemes:
--> 105             raise ValidationError(self.message, code=self.code)
    106

ValidationError: ['RELEASE_CHECK_URL must be a valid API URL. Example: https://api.github.com/repos/netbox-community/netbox']

During handling of the above exception, another exception occurred:

ImproperlyConfigured                      Traceback (most recent call last)
<ipython-input-4-8bf07c825907> in <module>
      9         validator(RELEASE_CHECK_URL)
     10     except ValidationError as err:
---> 11         raise ImproperlyConfigured(str(err))
     12

ImproperlyConfigured: ['RELEASE_CHECK_URL must be a valid API URL. Example: https://api.github.com/repos/netbox-community/netbox']

@jeremystretch
Copy link
Member

Thanks for the PR, but in the future please wait for the issue to be accepted per our contributing policy.

@jeremystretch jeremystretch merged commit 7e43745 into netbox-community:develop Mar 17, 2021
@jathanism jathanism deleted the jathanism-fix-invalid-release_check_url branch March 19, 2021 22:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid RELEASE_CHECK_URL never raises an error

2 participants