Git Datasource sync fails #10159

Closed
opened 2025-12-29 21:27:38 +01:00 by adam · 5 comments
Owner

Originally created by @as-nethinks on GitHub (Aug 30, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.0.8

Python Version

3.10

Steps to Reproduce

  1. created a remote GIT datasource (self hosted gitlab) with http authentication (Username and password)
  2. Manually lauched File sync

Expected Behavior

Expected sucessful sync of remote GIT repository

Observed Behavior

Sync Fails, history shows UnboundLocalError("local variable '_' referenced before assignment")

Bildschirmfoto 2024-08-30 um 16 36 29

Manually Cloning the Git Repository via HTTPS is possible from the Host netbox is installed.

Originally created by @as-nethinks on GitHub (Aug 30, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.0.8 ### Python Version 3.10 ### Steps to Reproduce 1. created a remote GIT datasource (self hosted gitlab) with http authentication (Username and password) 2. Manually lauched File sync ### Expected Behavior Expected sucessful sync of remote GIT repository ### Observed Behavior Sync Fails, history shows UnboundLocalError("local variable '_' referenced before assignment") ![Bildschirmfoto 2024-08-30 um 16 36 29](https://github.com/user-attachments/assets/c2c3976d-3531-4a0b-b44e-18e4380a6d5e) Manually Cloning the Git Repository via HTTPS is possible from the Host netbox is installed.
adam added the type: bug label 2025-12-29 21:27:38 +01:00
adam closed this issue 2025-12-29 21:27:38 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 3, 2024):

I'm not able to reproduce this on NetBox v4.0.10. Please try upgrading your installation and seeing if the issue remains.

@jeremystretch commented on GitHub (Sep 3, 2024): I'm not able to reproduce this on NetBox v4.0.10. Please try upgrading your installation and seeing if the issue remains.
Author
Owner

@as-nethinks commented on GitHub (Sep 3, 2024):

  • cloned Virtual machine that is hosting the productive system
  • Upgraded from v4.0.8 to v4.0.10 => Error still exists
  • Upgraded Python from 3.10 to 3.12 => Error still exists
  • Created a public accessible GIT Repo on Github and tried to clone it in Netbox as a Datasource (to rule out any issues with my self-hosted GitLAB) => error still exists
@as-nethinks commented on GitHub (Sep 3, 2024): - cloned Virtual machine that is hosting the productive system - Upgraded from v4.0.8 to v4.0.10 => Error still exists - Upgraded Python from 3.10 to 3.12 => Error still exists - Created a public accessible GIT Repo on Github and tried to clone it in Netbox as a Datasource (to rule out any issues with my self-hosted GitLAB) => error still exists
Author
Owner

@jeremystretch commented on GitHub (Sep 3, 2024):

See if you can capture the exception then. I was not able to reproduce this following the instructions above on NetBox v4.0.10.

@jeremystretch commented on GitHub (Sep 3, 2024): See if you can capture the exception then. I was not able to reproduce this following the instructions above on NetBox v4.0.10.
Author
Owner

@as-nethinks commented on GitHub (Sep 5, 2024):

could catch the exeption in the netbox-rq service

`Traceback (most recent call last):
  File "/opt/netbox/netbox/core/models/data.py", line 190, in sync
    backend = self.get_backend()
  File "/opt/netbox/netbox/core/models/data.py", line 173, in get_backend
    return self.backend_class(self.source_url, **backend_params)
  File "/opt/netbox/netbox/netbox/data_backends.py", line 31, in __init__
    self.config = self.init_config()
  File "/opt/netbox/netbox/core/data_backends.py", line 66, in init_config
    from dulwich.config import ConfigDict
ModuleNotFoundError: No module named 'dulwich'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/rq/worker.py", line 1430, in perform_job
    rv = job.perform()
  File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 1280, in perform
    self._result = self._execute()
  File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 1317, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/opt/netbox/netbox/core/jobs.py", line 33, in sync_datasource
    raise e
  File "/opt/netbox/netbox/core/jobs.py", line 20, in sync_datasource
    datasource.sync()
  File "/opt/netbox/netbox/core/models/data.py", line 193, in sync
    _("There was an error initializing the backend. A dependency needs to be installed: ") + str(e)
UnboundLocalError: local variable '_' referenced before assignment

after installing "dulwich" via PIP the GIT sync-job worked again.

I wonder why the documentation (https://netboxlabs.com/docs/netbox/en/stable/installation/3-netbox/#remote-data-sources) says that dulwich is an optional package in versions > v3.5

Issue can be closed.

@as-nethinks commented on GitHub (Sep 5, 2024): could catch the exeption in the netbox-rq service ``` `Traceback (most recent call last): File "/opt/netbox/netbox/core/models/data.py", line 190, in sync backend = self.get_backend() File "/opt/netbox/netbox/core/models/data.py", line 173, in get_backend return self.backend_class(self.source_url, **backend_params) File "/opt/netbox/netbox/netbox/data_backends.py", line 31, in __init__ self.config = self.init_config() File "/opt/netbox/netbox/core/data_backends.py", line 66, in init_config from dulwich.config import ConfigDict ModuleNotFoundError: No module named 'dulwich' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.10/site-packages/rq/worker.py", line 1430, in perform_job rv = job.perform() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 1280, in perform self._result = self._execute() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 1317, in _execute result = self.func(*self.args, **self.kwargs) File "/opt/netbox/netbox/core/jobs.py", line 33, in sync_datasource raise e File "/opt/netbox/netbox/core/jobs.py", line 20, in sync_datasource datasource.sync() File "/opt/netbox/netbox/core/models/data.py", line 193, in sync _("There was an error initializing the backend. A dependency needs to be installed: ") + str(e) UnboundLocalError: local variable '_' referenced before assignment ``` after installing "dulwich" via PIP the GIT sync-job worked again. I wonder why the documentation (https://netboxlabs.com/docs/netbox/en/stable/installation/3-netbox/#remote-data-sources) says that dulwich is an optional package in versions > v3.5 Issue can be closed.
Author
Owner

@jeremystretch commented on GitHub (Sep 5, 2024):

I wonder why the documentation says that dulwich is an optional package in versions > v3.5

Because it is optional. If you don't need to configure remote data sources using git, the package is not required.

@jeremystretch commented on GitHub (Sep 5, 2024): > I wonder why the documentation says that dulwich is an optional package in versions > v3.5 Because it is optional. If you don't need to configure remote data sources using git, the package is not required.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10159