Skip to content
Closed
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/openneuro-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"graphql-tools": "9.0.0",
"immutable": "^3.8.2",
"ioredis": "4.17.3",
"js-yaml": "^4.1.0",
"jsdom": "24.0.0",
"jsonwebtoken": "^9.0.0",
"keyv": "^4.5.3",
Expand Down Expand Up @@ -73,6 +74,7 @@
"@types/express-serve-static-core": "^4.17.35",
"@types/ioredis": "^4.17.1",
"@types/ioredis-mock": "^8.2.2",
"@types/js-yaml": "^4",
"@types/node-mailjet": "^3",
"@types/semver": "^5",
"core-js": "^3.10.1",
Expand Down
50 changes: 49 additions & 1 deletion packages/openneuro-server/src/datalad/description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { getDatasetWorker } from "../libs/datalad-service"
import CacheItem, { CacheType } from "../cache/item"
import { datasetOrSnapshot } from "../utils/datasetOrSnapshot"
import yaml from "js-yaml" // <--- ADD THIS IMPORT for js-yaml

/**
* Checks if all elements in an array are strings.
Expand All @@ -30,7 +31,9 @@
fileUrl(datasetId, "", "dataset_description.json", revision),
)
const contentType = res.headers.get("content-type")
if (res.status === 200 && contentType.includes("application/json")) {
// Added optional chaining for contentType here, as it might be null/undefined.
// This is a small, safe TypeScript improvement that often resolves linting.
if (res.status === 200 && contentType?.includes("application/json")) {
return await res.json()
} else {
throw new Error(
Expand Down Expand Up @@ -119,6 +122,46 @@
}
}

// --- NEW TEST FUNCTION TO READ AND LOG DATACITE.YML ---
const readAndLogDataciteYml = async (datasetId: string, revision: string) => {
const dataciteUrl = fileUrl(datasetId, "", "datacite.yml", revision)
try {
const res = await fetch(dataciteUrl)
if (res.status === 200) {
const text = await res.text()
try {
const parsedYaml: Record<string, unknown> = yaml.load(text) as Record<
string,
unknown
>
console.log(

Check failure on line 137 in packages/openneuro-server/src/datalad/description.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
`Found and successfully read datacite.yml for dataset ${datasetId} (revision: ${revision}):`,
parsedYaml,
)
} catch (parseErr) {
console.error(

Check failure on line 142 in packages/openneuro-server/src/datalad/description.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
`Found datacite.yml for dataset ${datasetId} (revision: ${revision}), but failed to parse it as YAML:`,
parseErr,
)
}
} else if (res.status === 404) {
console.log(

Check failure on line 148 in packages/openneuro-server/src/datalad/description.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
`datacite.yml not found for dataset ${datasetId} (revision: ${revision}).`,
)
} else {
console.warn(

Check failure on line 152 in packages/openneuro-server/src/datalad/description.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
`Attempted to read datacite.yml for dataset ${datasetId} (revision: ${revision}) and received status ${res.status}.`,
)
}
} catch (fetchErr) {
console.error(

Check failure on line 157 in packages/openneuro-server/src/datalad/description.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
`Error fetching datacite.yml for dataset ${datasetId} (revision: ${revision}):`,
fetchErr,
)
}
}
// --- END NEW FUNCTION ---

/**
* Get a parsed dataset_description.json
* @param {object} obj dataset or snapshot object
Expand All @@ -131,6 +174,11 @@
Name: datasetId,
BIDSVersion: "1.8.0",
}

// --- CALL TEST FNC datacite.yml ---
await readAndLogDataciteYml(datasetId, revision)
// --- END CALL TEST FNC ---

const cache = new CacheItem(redis, CacheType.datasetDescription, [
datasetId,
revision.substring(0, 7),
Expand Down
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3255,6 +3255,7 @@ __metadata:
"@types/express-serve-static-core": "npm:^4.17.35"
"@types/ioredis": "npm:^4.17.1"
"@types/ioredis-mock": "npm:^8.2.2"
"@types/js-yaml": "npm:^4"
"@types/node-mailjet": "npm:^3"
"@types/semver": "npm:^5"
base64url: "npm:^3.0.0"
Expand All @@ -3273,6 +3274,7 @@ __metadata:
immutable: "npm:^3.8.2"
ioredis: "npm:4.17.3"
ioredis-mock: "npm:^8.8.1"
js-yaml: "npm:^4.1.0"
jsdom: "npm:24.0.0"
jsonwebtoken: "npm:^9.0.0"
keyv: "npm:^4.5.3"
Expand Down Expand Up @@ -5028,6 +5030,13 @@ __metadata:
languageName: node
linkType: hard

"@types/js-yaml@npm:^4":
version: 4.0.9
resolution: "@types/js-yaml@npm:4.0.9"
checksum: 10/a0ce595db8a987904badd21fc50f9f444cb73069f4b95a76cc222e0a17b3ff180669059c763ec314bc4c3ce284379177a9da80e83c5f650c6c1310cafbfaa8e6
languageName: node
linkType: hard

"@types/jsdom@npm:^16":
version: 16.2.13
resolution: "@types/jsdom@npm:16.2.13"
Expand Down
Loading