Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/openneuro-server/src/datalad/description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,22 @@ export const repairDescriptionTypes = (description) => {
for (const field of arrayStringFields) {
if (Object.hasOwn(description, field)) {
if (!isArrayOfStrings(description[field])) {
// If it's not an array of strings (or not an array at all), replace with an empty array
newDescription[field] = []
// Check if the array is corrupted
if (Array.isArray(description[field])) {
newDescription[field] = description[field]
.map((item) => {
// If item is an object with a 'name' field (DataCite contributor), extract the name.
if (typeof item === "object" && item !== null && item.name) {
return String(item.name)
}
// Otherwise, attempt to stringify the item
return String(item)
})
.filter((s) => typeof s === "string" && s.trim().length > 0)
} else {
// If it's not an array at all (original logic)
newDescription[field] = []
}
}
// If it is already a valid array of strings, no change is needed.
}
Expand Down
Loading