Skip to content

Commit 7d105ff

Browse files
committed
Throw and error, do not just log an error, if provided schema is not readable
I think current behavior violates the principle of the least surprise: I ran validation while providing custom schema source, it executed with many warnings and errors reported to the screen. It is only after scrolling far up, I saw that actually my specification was wrong and operation resorted to built-in schema. amend: removed comment "version is ignored when the network cannot be accessed"
1 parent a01f420 commit 7d105ff

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Changed
2+
3+
- Throw an error if specified schema (e.g. via `--schema` or `BIDS_SCHEMA` env
4+
var) could not be loaded.

src/setup/loadSchema.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { setCustomMetadataFormats } from '../validators/json.ts'
66
/**
77
* Load the schema from the specification
88
*
9-
* version is ignored when the network cannot be accessed
109
*/
1110
export async function loadSchema(version?: string): Promise<Schema> {
1211
let schemaUrl = version
@@ -31,10 +30,10 @@ export async function loadSchema(version?: string): Promise<Schema> {
3130
objectPathHandler,
3231
) as Schema
3332
} catch (error) {
34-
// No network access or other errors
33+
// If a custom schema URL was explicitly provided, fail rather than falling back
3534
console.error(error)
36-
console.error(
37-
`Warning, could not load schema from ${schemaUrl}, falling back to internal version`,
35+
throw new Error(
36+
`Failed to load schema from ${schemaUrl}: ${error instanceof Error ? error.message : String(error)}`,
3837
)
3938
}
4039
}

0 commit comments

Comments
 (0)