Fixes #20933: Fix writable data_file assignment for ConfigContext and ConfigContextProfile via the REST API #583

Closed
opened 2026-04-05 16:47:17 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 1/14/2026

Fixes: #20933

This PR fixes the REST API behavior for assigning a ConfigContext (and ConfigContextProfile) to a synced DataFile.

Previously, data_file was marked read_only on the ConfigContext/ConfigContextProfile serializers, so PATCH/POST requests would silently ignore data_file (and data_path would not persist), even though the UI supports this workflow.

Changes included:

  • Removed read_only=True from the data_file field on the relevant ConfigContext and ConfigContextProfile serializers to allow setting it via the API (by ID).
  • Marked the appropriate fields in DataFileSerializer as read_only (e.g. path, last_updated, size, hash) since these values are managed by the data source sync process and should not be modified through the API.
  • Added API regression tests covering PATCHing data_source + data_file for both ConfigContext and ConfigContextProfile.

This brings the API in line with the UI and prevents silent no-op updates when referencing synced files.

*Originally created by @pheus on 1/14/2026* ### Fixes: #20933 This PR fixes the REST API behavior for assigning a `ConfigContext` (and `ConfigContextProfile`) to a synced `DataFile`. Previously, `data_file` was marked `read_only` on the `ConfigContext`/`ConfigContextProfile` serializers, so PATCH/POST requests would silently ignore `data_file` (and `data_path` would not persist), even though the UI supports this workflow. Changes included: - Removed `read_only=True` from the `data_file` field on the relevant `ConfigContext` and `ConfigContextProfile` serializers to allow setting it via the API (by ID). - Marked the appropriate fields in `DataFileSerializer` as `read_only` (e.g. `path`, `last_updated`, `size`, `hash`) since these values are managed by the data source sync process and should not be modified through the API. - Added API regression tests covering PATCHing `data_source` + `data_file` for both `ConfigContext` and `ConfigContextProfile`. This brings the API in line with the UI and prevents silent no-op updates when referencing synced files.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#583