Repository navigation
Fix/fill custom algo form - #131
filiperochalopes wants to merge 4 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3198b26e7c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| name: data.name || '', | ||
| description: data.description || '', | ||
| }); | ||
| updateSelected(key, metadataFields(data)); |
There was a problem hiding this comment.
Preserve duplicate-ID detection when adding canonical metadata
If two configured custom endpoints report the same ID, name and description but different valid canonical URLs, including canonical_url in this patch prevents updateSelected's filter(value, patch) from matching the first row. The second row therefore receives no conflict error, whereas the previous three-field patch detected the duplicate. This matters because MapProject.getAlgoDef selects the first configuration by ID and mergeIntoRowMatchState removes existing candidates with the incoming algorithm_id, so the endpoints can overwrite each other's results. Validate ID/name uniqueness independently of the full metadata patch.
Useful? React with 👍 / 👎.
snyaggarwal
left a comment
There was a problem hiding this comment.
Reviewed at 3198b26. I ran the new test file locally and all 7 tests pass.
Filling the canonical URL from metadata and sharing the validator both look good. Two things I'd change before merging, plus one question (details inline):
- Probe order. The stripped
/matchpath is now requested before the configured$matchURL. Endpoints that work today now take two requests, and they can pick up the wrong document. Trying the configured URL first, with the stripped path as the fallback, avoids both. - Duplicate ID/name check. I agree with the Codex comment. Adding
canonical_urlto the patch weakens the conflict check inupdateSelected. A fix is suggested inline. - Question: should metadata overwrite a canonical URL the user typed by hand?
The PR's browser check is still unticked. It's worth running against a server that serves metadata only on $match, to confirm the extra 404 on /match doesn't show up anywhere in the form.
| export const fetchAlgorithmMetadata = async (url, get) => { | ||
| const [path] = url.split(/[?#]/, 1) | ||
| const metadataUrl = path.replace(/\/\$([^/]+)(\/?)$/, '/$1$2') + url.slice(path.length) | ||
| const first = await get(metadataUrl) |
There was a problem hiding this comment.
This changes the request for endpoints that work today. If a GET on $match already returns metadata, we now send a GET to /match first. If that path returns any JSON with name and id, we fill the form from the wrong document and never ask the configured URL. Examples: a FHIR read of a resource with id match or translate (ConceptMap/$translate becomes ConceptMap/translate), or an unrelated REST resource.
Try url first, and fall back to the stripped path only when the response isn't usable metadata. Current endpoints then stay at one request, and the configured URL stays authoritative. The 401/403 preference would work the same way with the order swapped.
Was there a server that needed the stripped path first?
| name: data.name || '', | ||
| description: data.description || '', | ||
| }); | ||
| updateSelected(key, metadataFields(data)); |
There was a problem hiding this comment.
Two things about this patch:
- Agree with the Codex note.
updateSelectedrunsfilter(value, patch)with the whole patch. Withcanonical_urladded, two endpoints that share an ID and name but have different canonical URLs no longer get flagged.descriptionalready had the same gap, and the row also matches itself on re-verify. Checkingidandnameseparately, against the other rows only, fixes all three. For example,filter(value, v => v.__key !== key && v.id === patch.id)for the ID error, and the same for name. - Hand-entered values get replaced. A valid
canonical_urlfrom metadata now replaces what the user typed, on every URL or token blur. That matches how id, name and description already behave, so it may be fine. But if someone corrects the canonical URL by hand, the next check silently reverts it. Filling it only when the field is empty would avoid that. Your call.
| @@ -0,0 +1,27 @@ | |||
| // Match the form's URL validation when accepting metadata from a custom API. | |||
There was a problem hiding this comment.
Nit: this is now the form's validator itself, so "Match the form's URL validation" reads oddly. The old comment in algorithms.jsx explained why custom algorithms need it (concept_identity.canonical_url must be a URL). Worth bringing that over.
|
There's no ticket for this change. The PR body says no tracking issue is linked, and the commits don't reference one. Please file a ticket in OpenConceptLab/ocl_issues first, describing the problem (custom algorithm form not filling the canonical URL from metadata, and servers that serve discovery on the path without |
PR Notes —
fix/fill-custom-algo-formTL;DR: The custom algorithm form now fills
canonical_urlfrom the algorithm's discovery GET, finds that metadata on up to three URLs, and no longer flags an algorithm as conflicting with itself. No tracking issue linked.Main Changes
src/components/map-projects/MultiAlgoSelector.jsx(+9/−17)canonical_url) to the form; verify the endpoint through the metadata fallback; useconflictingFieldsfor ID/name conflicts; drop the unusedfilterimport.src/components/map-projects/customAlgoMetadata.js(+39/−0)metadataFields(validcanonical_urlonly),fetchAlgorithmMetadata(three-step GET discovery) andconflictingFields(ID/name conflicts against other algorithms).src/components/map-projects/algorithms.jsx(+2/−7)isLikelyCanonicalUrlfrom the new module, so existing imports keep working.src/components/map-projects/__tests__/customAlgoMetadata.test.js(+132/−0)Net diff against
origin/main: 4 files, +182/−24. Commits:2370122,3198b26,c800ed0,74f1b88.Discovery order
The configured URL is the one the Mapper POSTs
$matchto; discovery only changes which URLs are read with GET. Example forhttps://host/api/ciel-bridge-rxnorm/$match:https://host/api/ciel-bridge-rxnorm/matchnameandID/idhttps://host/api/ciel-bridge-rxnorm/$matchhttps://host/api/ciel-bridge-rxnormA URL without
$is requested once. Query strings, fragments and a trailing slash are preserved. If every step fails, a 401/403 from any step is the reported error (token-required feedback); otherwise the last response is.Key Decisions
canonical_urlfrom the GET when it is a valid http(s) URL.$, original, then parent path.GET /api/<name>next toPOST /api/<name>/$match)..jsmodule instead ofalgorithms.jsx.algorithms.jsximports React/MUI and cannot be loaded bynode --test.Verification Checklist
npm test: 681 passed, 0 failed (baseline before this branch: 667).npm run test:integration: 11 passed.npm run eslint: no findings.