Bug: `$clone` leaves `from_source_url` (and `to_source_url`) pointing at the original source on copied mappings

オープン 初心者向け
#3,012 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
領域
backend

調査の方向性

core/sources/models.py の clone_mappings() から始めて、Mapping.clone() がソース URL をどのようにコピーするか確認してください。割り当てられた概念の親 URI と、コピーされた from_source_url および to_source_url の値を比較し、これらのフィールドが割り当てられた概念と一致するようにクローン処理を更新してください。$clone でコピーされたマッピングが、マッピング詳細/API レスポンスで対象ソース URL を返すようになれば完了です。

索引モデルが issue の本文から書いたものです。

説明

component/api decision/human-review signal/needs-access signal/quick-win signal/small-scope signal/well-specified stage/triaged type/bug

Expected Behavior

When a concept is cloned into another source with $clone, each copied mapping belongs to the target source and starts from the new concept. So its from_source_url should be the target source, e.g. /orgs/PIH/sources/PIH/. More generally, from_source_url/to_source_url should match from_concept_url/to_concept_url and from_source_name/to_source_name.

Current Behavior

from_source_url keeps the value from the original mapping, i.e. the source the concept was cloned from, while from_concept_url and from_source_name are updated.

Example: PIH 21400 was cloned from CIEL 170656. CIEL mapping /orgs/CIEL/sources/CIEL/mappings/17052749/ is SAME-AS LOINC:53625-0. The copy, https://app.v3.openconceptlab.org/orgs/PIH/sources/PIH/mappings/44946/, has:

field value
from_concept_url /orgs/PIH/sources/PIH/concepts/21400/
from_source_name PIH
from_source_url /orgs/CIEL/sources/CIEL/
to_* LOINC 53625-0 (correct)

When the clone also retargets a mapping to a concept in the target source (see #3013), to_source_url isn't updated either. Example: https://app.v3.openconceptlab.org/orgs/PIH/sources/PIH/mappings/46475/ has to_concept_url=/orgs/PIH/sources/PIH/concepts/21768/ and to_source_name=PIH, but to_source_url=/orgs/CIEL/sources/CIEL/.

The concept view labels mappings by *_source_name, so the problem is only visible in the mapping detail/edit view or the API.

Possible Solution

In core/sources/models.py clone_mappings(), the code sets from_concept_id, from_concept_code, from_source_id (and the to_* equivalents) from the assigned concepts, but not from_source_url/to_source_url. Mapping.clone() copies those URLs from the original. Setting them from the assigned concepts' parent (concept.parent.uri) would fix it.

Steps to Reproduce

  1. Pick a CIEL concept with mappings to other sources, e.g. CIEL 170656.
  2. Clone it into a source you can edit, using TermBrowser "Clone to source" (v2 or v3) or POST <target source>/concepts/$clone/ with equivalencyMapType=SAME-AS.
  3. GET the new concept with ?includeMappings=true, then GET one of its copied mappings with ?verbose=true.
  4. from_source_url is the CIEL source, not the target source.

Context (Environment)

Production (api.openconceptlab.org), PIH organization source /orgs/PIH/sources/PIH/. In release 1.8.46 about 3,850 copied mappings have this, going back to March 2024. The OpenMRS OCL module doesn't use from_source_url, so imports aren't affected, but the data is inconsistent and confusing for anyone reading or editing the mappings.

Detailed Description

Found while investigating a related, more serious clone problem: mappings to external code systems being retargeted to concepts in the target source (#3013). That issue also leaves to_source_url stale.

主要言語
言語のデータがありません
スター
4
フォーク
2
平均マージ
2時間 12分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenConceptLab/ocl_issues のほかの issue

OpenConceptLab/ocl_issues の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。