fix: normalize orcid use everywhere#3610
Open
tefkah wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses DOI submission failures caused by inconsistent ORCID storage (full orcid.org URLs vs bare ORCID identifiers) by normalizing ORCID values at ingestion points and adding a migration to clean existing data.
Changes:
- Introduces a shared
normalizeOrcidhelper and applies it across exports/transforms and Crossref contributor generation. - Tightens API/user handling to accept ORCID IDs or URLs and persist only the bare identifier.
- Adds a migration to strip
orcid.orgURL prefixes from existing ORCID columns.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| workers/tasks/export/pandoc.ts | Normalizes ORCID before emitting Pandoc YAML metadata. |
| workers/tasks/communityExport.tsx | Normalizes ORCID before building orcid.org links in community exports. |
| utils/orcid.ts | Adds normalizeOrcid helper for extracting a bare ORCID identifier. |
| utils/crossref/schema/contributors.js | Normalizes ORCID before emitting Crossref ORCID fields/URLs. |
| utils/api/schemas/user.ts | Validates ORCID as ID-or-URL and transforms to bare identifier in the user API schema. |
| tools/migrations/2026_05_13_normalizeOrcids.js | Migrates existing ORCID values to bare identifiers by stripping URL prefixes. |
| server/user/queries.ts | Normalizes ORCID on create/update and rejects invalid values on update. |
| deposit/transform/pub.ts | Normalizes ORCID in pub deposit resource contribution output. |
| deposit/transform/collection.ts | Normalizes ORCID in collection deposit resource contribution output. |
| client/containers/User/UserHeader.tsx | Normalizes ORCID before rendering the ORCID profile link. |
| client/components/ContributorsList/Contributor.tsx | Normalizes ORCID before rendering/displaying contributor ORCID links. |
Comments suppressed due to low confidence (1)
server/user/queries.ts:104
- User ORCID updates are now normalized/validated via normalizeOrcid and can throw "Invalid ORCID". There are currently no tests in server/user/tests exercising these cases (valid bare ID, valid URL, invalid string, clearing to null/empty). Please add test coverage to ensure the endpoint consistently normalizes and rejects invalid values.
if (filteredValues.orcid) {
const normalized = normalizeOrcid(filteredValues.orcid as string);
if (!normalized) {
throw new Error('Invalid ORCID');
}
filteredValues.orcid = normalized;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
34
to
40
| title: inputValues.title, | ||
| bio: inputValues.bio, | ||
| location: inputValues.location, | ||
| website: inputValues.website, | ||
| orcid: inputValues.orcid, | ||
| orcid: normalizeOrcid(inputValues.orcid), | ||
| github: inputValues.github, | ||
| twitter: inputValues.twitter, |
Comment on lines
+11
to
+15
| export const normalizeOrcid = (value: string | null | undefined): string | null => { | ||
| if (!value) return null; | ||
|
|
||
| const match = value.match(/(\d{4}-){3}\d{3}(\d|X)/); | ||
| return match?.[0] ?? null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue(s) Resolved
There was an issue submitting DOIs for a Pub bc someone still had their ORCID set as
https://orcid.org/xxxx-xxx-xxx-xxxrather thanxxxx-xxxx-xxx-xxx. We at some point started requiring the latter, but never ended up doing a migration to change all of the existing ones.I added some extra checks everywhere ORCIDs where used, as well as in the API, plus said migration to make sure this doesn't happen.
Test Plan
Screenshots (if applicable)
Optional
Notes/Context/Gotchas
Supporting Docs