Repository navigation
Skip empty funder and creator entries in DataCite XML - #466
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR466Version: 🤖 Updated on each push. |
PR #466 Review — Skip empty funder/creator entries in DataCite XMLSummaryTests: 128/128 pass. Typecheck clean. The two-layer fix is correct in intent and addresses the root cause. A few gaps remain. Critical (0)None. The primary EZID rejection scenario (empty Important (2)1. The DataCite kernel-4 XSD uses if (fund.awardNumber) { … escapeXml(fund.awardNumber) … }
if (fund.awardTitle) { … escapeXml(fund.awardTitle) … }A whitespace-only if (fund.awardNumber?.trim()) {
lines.push(` <awardNumber${uriAttr}>${escapeXml(fund.awardNumber.trim())}</awardNumber>`);
}
if (fund.awardTitle?.trim()) {
lines.push(` <awardTitle>${escapeXml(fund.awardTitle.trim())}</awardTitle>`);
}2. The guard Suggestions (3)3. Two-layer design: source-layer is NOT dead code; both layers serve distinct purposes This is intentional and correct. The source-layer filter in 4. The "throws on all-empty creators" path propagates as an uncaught exception in all callers
5. In const title = (typeof rawName === "string" ? rawName : undefined) || datasetId;A Similarly, Nice-to-haves (1)6. Zero-width spaces ( False positives (0)None of the findings are false positives. All relate to observable gaps. VerdictMergeable after addressing finding #1 ( |
Apply trim-and-length guards to awardNumber and awardTitle in buildDataCiteXml so whitespace-only values are suppressed. Also trim uploaderName before pushing to contributors so surrounding whitespace does not appear in emitted XML. Adds tests for whitespace-only awardNumber/awardTitle suppressed, padded values emitted trimmed, and padded uploaderName emitted trimmed.
Review findings addressed (commit a31c196)Finding 1: awardNumber/awardTitle whitespace-only values Changed Finding 2: uploaderName pushed untrimmed Extracted Tests added (3 new):
All 131 tests pass. |
Closes #459.
Summary
EZID validates submitted DataCite XML against the kernel-4 XSD, which
enforces
minLength=1on<funderName>,<creatorName>, and<contributorName>. When BIDSFundingorAuthorscontained anempty or whitespace-only string,
bidsToDataCite()emitted<funderName/>/<creatorName/>and EZID rejected the entireDataCite document, failing the DOI mint.
Fix is filtered at two layers:
bidsToDataCite) — trim and drop empty entries fromBIDS
Funding, enrichmentfundingInfo, BIDSAuthors, and theoptional
uploaderNamecontributor before they ever reach the XMLbuilder. Whitespace is normalized via
.trim()on the survivingfunder names.
buildDataCiteXml) — filter again at emit time so adirect caller that built
DataCiteMetadatamanually (admintooling, future LLM-enrich path) can't bypass the source filter.
The funders block is skipped entirely if every entry is junk; the
creators block throws (matches the existing "at least one creator"
contract). Contributors silently drop empty entries (the XML block
is already optional).
The existing XSD-min-length validations on
<title>and<publisher>were already covered by the early-validation checks at the top of
buildDataCiteXml, so no new guards are needed there.Test plan
bun test test/datacite.test.ts— 128/128 pass (9 new testscover: funder filter with mixed valid/empty, all-empty funder block
drop, contributor filter, all-empty creator throw, mixed creator
filter, BIDS funding source filter, enrichment fundingInfo source
filter, BIDS Authors source filter, and the symmetric scenario from
the issue reproduction).
cd backend && bun run typecheckbun run builddatacite,manifest,llm-enrich-ref-validation,license-provenance,ezid, anddoi-orcid-discoverytest files: 262/262 pass.