Skip to content

fix: normalize orcid use everywhere#3610

Open
tefkah wants to merge 1 commit into
mainfrom
tfk/fix-doi-orcid
Open

fix: normalize orcid use everywhere#3610
tefkah wants to merge 1 commit into
mainfrom
tfk/fix-doi-orcid

Conversation

@tefkah
Copy link
Copy Markdown
Member

@tefkah tefkah commented May 13, 2026

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-xxx rather than xxxx-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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 normalizeOrcid helper 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.org URL 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 thread server/user/queries.ts
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 thread utils/orcid.ts
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants