Sync private repo fails with malformed URL #7789

Closed
opened 2025-12-29 20:28:14 +01:00 by adam · 0 comments
Owner

Originally created by @abhi1693 on GitHub (Mar 23, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.5.0

Python version

3.10

Steps to Reproduce

  1. Use any git repo link for the data source
  2. Enter your username
  3. Create a token with full repo scope and use that as password

Expected Behavior

Sync should work.

This can be fixed by making the following change

diff --git a/netbox/core/data_backends.py b/netbox/core/data_backends.py
index 96b8d7d4f..67dc63352 100644
--- a/netbox/core/data_backends.py
+++ b/netbox/core/data_backends.py
@@ -93,7 +93,7 @@ class GitBackend(DataBackend):
         if username and password:
             url_components = list(urlparse(self.url))
             # Prepend username & password to netloc
-            url_components[1] = quote(f'{username}@{password}:') + url_components[1]
+            url_components[1] = f'{username}:{password}@' + url_components[1]
             url = urlunparse(url_components)
         else:
             url = self.url

Observed Behavior

Sync fails with error

Fetching remote data failed: .... URL using bad/illegal format or missing URL
Originally created by @abhi1693 on GitHub (Mar 23, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.5.0 ### Python version 3.10 ### Steps to Reproduce 1. Use any git repo link for the data source 2. Enter your username 3. Create a token with full repo scope and use that as password ### Expected Behavior Sync should work. This can be fixed by making the following change ``` diff --git a/netbox/core/data_backends.py b/netbox/core/data_backends.py index 96b8d7d4f..67dc63352 100644 --- a/netbox/core/data_backends.py +++ b/netbox/core/data_backends.py @@ -93,7 +93,7 @@ class GitBackend(DataBackend): if username and password: url_components = list(urlparse(self.url)) # Prepend username & password to netloc - url_components[1] = quote(f'{username}@{password}:') + url_components[1] + url_components[1] = f'{username}:{password}@' + url_components[1] url = urlunparse(url_components) else: url = self.url ``` ### Observed Behavior Sync fails with error ``` Fetching remote data failed: .... URL using bad/illegal format or missing URL ```
adam added the type: bugstatus: acceptedbeta labels 2025-12-29 20:28:15 +01:00
adam closed this issue 2025-12-29 20:28:15 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7789