Create a config context based on a data source not possible via API #11147

Open
opened 2025-12-29 21:40:57 +01:00 by adam · 6 comments
Owner

Originally created by @GoepiGB on GitHub (May 8, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.3.0

Python Version

3.10

Steps to Reproduce

  1. Create and sync a datasource
  2. Create a config context using a file from this datasource via API

Expected Behavior

Have a config context that is based on the file from the data source, the same way as if you would create it via the GUI

Observed Behavior

You get a config context with the data from the "data" field (which is mandatory) that you supplied through the API call.
The data source field gets written to the created config context, but the "data_file" field is completely ignored.
The field for auto-syncing from the data source is also missing from the API.
Even a PATCH after creating the config context with a value in the "data_file" field gets ignored completely; there isn't even an entry in the change log.

The JSON I POSTed via API:
{ "name": "some template", "data_file": 1, "data_source": { "name": "some data source" }, "weight": 1000, "data": { "1": 1 }, "is_active": true }

The object that was created:
{ "id": 2, "url": "http://netboxurl/api/extras/config-contexts/2/", "display_url": "http://netboxurl/extras/config-contexts/2/", "display": "some template", "name": "some template", "weight": 1000, "description": "", "is_active": true, "regions": [], "site_groups": [], "sites": [], "locations": [], "device_types": [], "roles": [], "platforms": [], "cluster_types": [], "cluster_groups": [], "clusters": [], "tenant_groups": [], "tenants": [], "tags": [], "data_source": { "id": 1, "url": "http://netboxurl/api/core/data-sources/1/", "display": "some data source", "name": "some data source", "description": "" }, "data_path": "", "data_file": null, "data_synced": null, "data": { "1": 1 }, "created": "2025-05-08T15:00:01.599408Z", "last_updated": "2025-05-08T15:00:03.146693Z" }

Originally created by @GoepiGB on GitHub (May 8, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.3.0 ### Python Version 3.10 ### Steps to Reproduce 1. Create and sync a datasource 2. Create a config context using a file from this datasource via API ### Expected Behavior Have a config context that is based on the file from the data source, the same way as if you would create it via the GUI ### Observed Behavior You get a config context with the data from the "data" field (which is mandatory) that you supplied through the API call. The data source field gets written to the created config context, but the "data_file" field is completely ignored. The field for auto-syncing from the data source is also missing from the API. Even a PATCH after creating the config context with a value in the "data_file" field gets ignored completely; there isn't even an entry in the change log. The JSON I POSTed via API: `{ "name": "some template", "data_file": 1, "data_source": { "name": "some data source" }, "weight": 1000, "data": { "1": 1 }, "is_active": true }` The object that was created: `{ "id": 2, "url": "http://netboxurl/api/extras/config-contexts/2/", "display_url": "http://netboxurl/extras/config-contexts/2/", "display": "some template", "name": "some template", "weight": 1000, "description": "", "is_active": true, "regions": [], "site_groups": [], "sites": [], "locations": [], "device_types": [], "roles": [], "platforms": [], "cluster_types": [], "cluster_groups": [], "clusters": [], "tenant_groups": [], "tenants": [], "tags": [], "data_source": { "id": 1, "url": "http://netboxurl/api/core/data-sources/1/", "display": "some data source", "name": "some data source", "description": "" }, "data_path": "", "data_file": null, "data_synced": null, "data": { "1": 1 }, "created": "2025-05-08T15:00:01.599408Z", "last_updated": "2025-05-08T15:00:03.146693Z" }`
adam added the type: bugstatus: needs ownernetboxseverity: low labels 2025-12-29 21:40:57 +01:00
Author
Owner

@jnovinger commented on GitHub (May 12, 2025):

Thank you for opening a bug report, @GoepiGB . Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@jnovinger commented on GitHub (May 12, 2025): Thank you for opening a bug report, @GoepiGB . Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.
Author
Owner

@GoepiGB commented on GitHub (May 14, 2025):

@jnovinger

  1. Create a data source with the name "DS" in Netbox (use https://github.com/GoepiGB/netbox-issue-19438.git as source)
  2. Sync the data source
  3. Create a config context via API with the following command:
    curl -H "Authorization: Token <token>" -H "Content-Type: application/json" -X POST "<netboxurl>/api/extras/config-contexts/" -d '{"name": "Test template", "data_file": {"path": "test-config-context.json"}, "data_source": {"name": "DS"}, "data": {"key": "val"}}'

You will get a config context with the data from the API call, but the data from the file or the file itself in the "data_file" field is missing.

I hope this can clarify the issue.

@GoepiGB commented on GitHub (May 14, 2025): @jnovinger 1. Create a data source with the name "DS" in Netbox (use [https://github.com/GoepiGB/netbox-issue-19438.git](https://github.com/GoepiGB/netbox-issue-19438.git) as source) 2. Sync the data source 3. Create a config context via API with the following command: `curl -H "Authorization: Token <token>" -H "Content-Type: application/json" -X POST "<netboxurl>/api/extras/config-contexts/" -d '{"name": "Test template", "data_file": {"path": "test-config-context.json"}, "data_source": {"name": "DS"}, "data": {"key": "val"}}'` You will get a config context with the data from the API call, but the data from the file or the file itself in the "data_file" field is missing. I hope this can clarify the issue.
Author
Owner

@github-actions[bot] commented on GitHub (May 22, 2025):

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

@github-actions[bot] commented on GitHub (May 22, 2025): This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.
Author
Owner

@jnovinger commented on GitHub (May 22, 2025):

Apologies for not getting back to this sooner, @GoepiGB . I've been having some issues getting a git-based Data Source to work. I plan to figure that out today and finish up triage.

@jnovinger commented on GitHub (May 22, 2025): Apologies for not getting back to this sooner, @GoepiGB . I've been having some issues getting a git-based Data Source to work. I plan to figure that out today and finish up triage.
Author
Owner

@jnovinger commented on GitHub (May 22, 2025):

Finally figured this out. It was picking up my configured Github username from ~/.gitconfig and then not finding a password, so auth failed. I'm a little confused why it still didn't work when I added values to the data source for git username and password. Might need to track that down.

@jnovinger commented on GitHub (May 22, 2025): Finally figured this out. It was picking up my configured Github username from `~/.gitconfig` and then not finding a password, so auth failed. I'm a little confused why it still didn't work when I added values to the data source for git username and password. Might need to track that down.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 21, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Aug 21, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11147