Repository: netbox-community/netbox

Issue:
Git DataSource sync fails when HTTP proxies are configured
### NetBox version

v3.5.0

### Python version

3.8

### Steps to Reproduce

1.  Configure HTTP_PROXIES in configuration.py
2. Run a Git based Data Source sync

```
HTTP_PROXIES = {
    'http': 'http://xxx.xxx.xxx.xxx:3128',
    'https': 'http://xxx.xxx.xxx.xxx:3128',
}
```



### Expected Behavior

If you have HTTP_PROXIES configured, the sync task fails. If you comment out that section of the config, then restart the netbox-rq service, the sync works.

### Observed Behavior

```
May  4 12:39:20 it-netbox python3[141419]: 12:39:20 default: core.jobs.sync_datasource(job=<Job: 54fd9fa1-a5b8-49de-ae4f-6a2288d2fd50>) (54fd9fa1-a5b8-49de-ae4f-6a2288d2fd50)
May  4 12:39:21 it-netbox python3[236504]: 12:39:21 [Job 54fd9fa1-a5b8-49de-ae4f-6a2288d2fd50]: exception raised while executing (core.jobs.sync_datasource)
May  4 12:39:21 it-netbox python3[236504]: Traceback (most recent call last):
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox/venv/lib/python3.8/site-packages/rq/worker.py", line 1359, in perform_job
May  4 12:39:21 it-netbox python3[236504]:     rv = job.perform()
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox/venv/lib/python3.8/site-packages/rq/job.py", line 1178, in perform
May  4 12:39:21 it-netbox python3[236504]:     self._result = self._execute()
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox/venv/lib/python3.8/site-packages/rq/job.py", line 1215, in _execute
May  4 12:39:21 it-netbox python3[236504]:     result = self.func(*self.args, **self.kwargs)
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox-3.5.0/netbox/core/jobs.py", line 33, in sync_datasource
May  4 12:39:21 it-netbox python3[236504]:     raise e
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox-3.5.0/netbox/core/jobs.py", line 20, in sync_datasource
May  4 12:39:21 it-netbox python3[236504]:     datasource.sync()
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox-3.5.0/netbox/core/models/data.py", line 155, in sync
May  4 12:39:21 it-netbox python3[236504]:     with backend.fetch() as local_path:
May  4 12:39:21 it-netbox python3[236504]:   File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
May  4 12:39:21 it-netbox python3[236504]:     return next(self.gen)
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox-3.5.0/netbox/core/data_backends.py", line 99, in fetch
May  4 12:39:21 it-netbox python3[236504]:     config.set("http", "proxy", proxy)
May  4 12:39:21 it-netbox python3[236504]:   File "/opt/netbox/venv/lib/python3.8/site-packages/dulwich/config.py", line 735, in set
May  4 12:39:21 it-netbox python3[236504]:     return self.writable.set(section, name, value)
May  4 12:39:21 it-netbox python3[236504]: NotImplementedError: <bound method StackedConfig.set of <StackedConfig for []>>
```


Discussion:

Resolving patch:
diff --git a/netbox/core/data_backends.py b/netbox/core/data_backends.py
--- a/netbox/core/data_backends.py
+++ b/netbox/core/data_backends.py
@@ -12,7 +12,7 @@
 from django.conf import settings
 from django.utils.translation import gettext as _
 from dulwich import porcelain
-from dulwich.config import StackedConfig
+from dulwich.config import ConfigDict
 
 from netbox.registry import registry
 from .choices import DataSourceTypeChoices
@@ -91,7 +91,7 @@ class GitBackend(DataBackend):
     def fetch(self):
         local_path = tempfile.TemporaryDirectory()
 
-        config = StackedConfig.default()
+        config = ConfigDict()
         clone_args = {
             "branch": self.params.get('branch'),
             "config": config,


Test patch: