-
Notifications
You must be signed in to change notification settings - Fork 1
Description
What version are you using?
v1.0.3
Describe the Bug
When using @frictionless-ts/metadata in a browser environment (e.g., the datapackage-validator), validating a datapackage with local file paths throws "File system is not supported in this environment".
Version
Affects all versions including latest (v1.0.3). Tested via the validator which uses v1.0.1.
Reproducing
Go to https://datapackage-validator.datist.io/, select Text tab, and try these:
Works (remote URL):
{"name":"test","resources":[{"name":"data","path":"https://example.com/data.csv"}]}Works (inline data):
{"name":"test","resources":[{"name":"data","data":[["a","b"],["1","2"]]}]}Fails (local path):
{"name":"test","resources":[{"name":"data","path":"data.csv"}]}Why this matters
Local file paths like "path": "data.csv" are valid in the Data Package spec - they're relative POSIX paths meant to be resolved from wherever the datapackage.json lives. For metadata-only validation (checking structure, not reading files), there's no need to actually resolve these paths.
I ran into this while working on vega/vega-datasets#755.
Suggested fix
In metadata/path/normalize.ts, instead of throwing when node is undefined, return the path as-is:
if (!node) {
return options.basepath ? [options.basepath, path].join("/") : path
}The same pattern applies to the other files that throw this error (basepath.ts, denormalize.ts, path.ts).
Participation
- I am willing to submit a pull request for this issue.