fix(pairedData): return null source for deleted parent projects DEV-2034#7218
fix(pairedData): return null source for deleted parent projects DEV-2034#7218platreth wants to merge 2 commits into
Conversation
|
| return source__name | ||
|
|
||
| def to_representation(self, instance): | ||
| source_deleted = self._source_is_deleted(instance) |
There was a problem hiding this comment.
Let's move this line inside __get_source_asset_url() and get_source__name() and return None (change their signature accordingly).
You can decorate _source_is_deleted with @cache_for_request to avoid calling the DB twice.
in both methods, if self._source_is_deleted() returns None, we return right away, in the representation, no need to add conditions anymore. It would be handled inside other methods.
On the side note. That's not great. I think we should move away from the JSON Field and give PairedData its own db model and use FKs. Would you mind to create a linear issue for that?
📣 Summary
When a source project used for a connected (paired) dataset is deleted, it is now clearly reported as deleted rather than still appearing as a normal source.
📖 Description
Connected projects pull data from a "source" project. If that source project was deleted, the paired-data endpoint kept listing it as if it were a live source, which the connected-projects UI couldn't reliably detect. The deleted source's
sourcelink is now returned asnull, giving the frontend a dependable signal.💭 Notes
paired_datais stored as a JSON blob on the destinationAssetkeyed by source uid, with no cascading FK, so deleting a source asset leaves a dangling reference (DEV-2034).PairedDataSerializer.to_representationnow emitssource: nullwhen the source Asset row no longer exists, detected by reusing thesource__namesmapping the viewset already builds (uid absent ⇒ row deleted) — no extra query on the list endpoint, with a direct.exists()fallback when context is absent. Runtime-only change: no OpenAPI schema drift, no migration.👀 Preview steps
GET /api/v2/assets/<B_uid>/paired-data/.GET /api/v2/assets/<B_uid>/paired-data/again."source"URL (only"source__name"is null)."source"isnull.