nautobot / nautobot

Network Source of Truth & Network Automation Platform
https://docs.nautobot.com
Apache License 2.0
944 stars 254 forks source link

GitRepository URL Validator does not allow for local DNS URLs #5819

Closed MeganerdDev closed 1 week ago

MeganerdDev commented 2 weeks ago

Environment

Steps to Reproduce

  1. Navigate to extras/git-repositories in the Nautobot UI
  2. Press the Add button to begin creating a new GIT Repository object
  3. On the Remote URL charfield entry provide a local DNS name eg: https://local-dns-example/golden-config-backup.git
  4. Fill in remaining required entries and press Update & Sync button

Expected Behavior

Object created and syncs as normal operation

Observed Behavior

URL validator throws an error preventing creation of the object image

Additional Details

MeganerdDev commented 2 weeks ago

I was able to mitigate this over the ORM for now

from nautobot.extras.models import GitRepository

GitRepository.objects.create(
    name="test",
    slug="test",
    remote_url="https://local-dns-example/golden-config-backup.git",
    branch="main"
)

Also unrelated to the URL Validator for local DNS names, but local pathfiles might also be considered during any refactoring change that is done to this entry? I had a separate case where I worked around this by creating the object over ORM

glennmatthews commented 1 week ago

Nautobot has a custom nautobot.core.models.validators.EnhancedURLValidator that supports hostnames, it looks like it might just be as simple as fixing the GitRepository definition to use that instead of Django's default URLValidator.

glennmatthews commented 1 week ago

Similarly the form itself needs to use nautobot.core.forms.fields.LaxURLField instead of Django's forms.URLField.