schema_salad
schema_salad copied to clipboard
`$base` is ignored in `$include` directive
The spec of $include says:
The URI string must be resolved to an absolute URI using the link resolution rules described previously. The URI referenced by
$includemust be loaded as a text data.
Also, the spec of explicit context says that $base sets the base URI that is used in the link resolution.
However, schema-salad-tool resolves the path relative reference in $include directive with the default base URI rather than the value of $base field.
Inputs
/workspaces/salad/sample.yml:
$base: "https://raw.githubusercontent.com/common-workflow-language/schema_salad/main/"
$graph:
- name: Doc
type: documentation
doc:
$include: lgtm.yml
In my understanding, lgtm.yml in the $include directive is resolved to https://raw.githubusercontent.com/common-workflow-language/schema_salad/main/lgtm.yml according to the link resolution rule.
Expected behavior
https://raw.githubusercontent.com/common-workflow-language/schema_salad/main/lgtm.yml is loaded and $include directive is replaced with the loaded string as follows:
$ schema-salad-tool --print-pre sample.yml
/usr/local/bin/schema-salad-tool Current version: 8.2.20211222191353
[
{
"name": "https://raw.githubusercontent.com/common-workflow-language/schema_salad/main/#Doc",
"type": "documentation",
"doc": "extraction: \n # Define settings for JavaScript analysis\n ##########################################\n javascript:\n # The `index` step extracts information from the files in the codebase.\n index:\n # Specify a list of files and folders to exclude from extraction.\n exclude:\n - schema_salad/typescript/\n"
}
]
Actual behavior
lgtm.yml is resolved to /workspaces/salad/lgtm.yml and schema-salad-tool fails to load it.
I guess schema-salad-tool uses file:///workspaces/salad/sample.yml (i.e., the default base URI that is described in the implied context) as the base URI.
$ schema-salad-tool --print-pre sample.yml
/usr/local/bin/schema-salad-tool Current version: 8.2.20211222191353
loader is 140079248226064
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/schema_salad/fetcher.py", line 86, in fetch_text
urllib.request.url2pathname(str(path)), encoding="utf-8"
FileNotFoundError: [Errno 2] No such file or directory: '/workspaces/salad/lgtm.yml'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 903, in resolve_all
val, base_url + subscope, file_base=file_base, checklinks=False
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 832, in resolve_all
strict_foreign_properties=strict_foreign_properties,
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 501, in resolve_ref
return self.fetch_text(url), CommentedMap()
File "/usr/local/lib/python3.6/dist-packages/schema_salad/fetcher.py", line 92, in fetch_text
raise ValidationException(str(err)) from err
schema_salad.exceptions.ValidationException: [Errno 2] No such file or directory: '/workspaces/salad/lgtm.yml'
failed
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/schema_salad/fetcher.py", line 86, in fetch_text
urllib.request.url2pathname(str(path)), encoding="utf-8"
FileNotFoundError: [Errno 2] No such file or directory: '/workspaces/salad/lgtm.yml'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 903, in resolve_all
val, base_url + subscope, file_base=file_base, checklinks=False
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 832, in resolve_all
strict_foreign_properties=strict_foreign_properties,
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 501, in resolve_ref
return self.fetch_text(url), CommentedMap()
File "/usr/local/lib/python3.6/dist-packages/schema_salad/fetcher.py", line 92, in fetch_text
raise ValidationException(str(err)) from err
schema_salad.exceptions.ValidationException: [Errno 2] No such file or directory: '/workspaces/salad/lgtm.yml'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 947, in resolve_all
val, base_url, file_base=file_base, checklinks=False
File "/usr/local/lib/python3.6/dist-packages/schema_salad/ref_resolver.py", line 913, in resolve_all
) from v
schema_salad.exceptions.ValidationException: (140079248226064) (file:///workspaces/salad/sample.yml) Validation error in field doc:
[Errno 2] No such file or directory: '/workspaces/salad/lgtm.yml'
Schema `sample.yml` failed link checking:
(140079248226064) (file:///workspaces/salad/sample.yml) Validation error in position 0:
(140079248226064) (file:///workspaces/salad/sample.yml) Validation error in field doc:
[Errno 2] No such file or directory: '/workspaces/salad/lgtm.yml'
versions
$ schema-salad-tool --version
/usr/local/bin/schema-salad-tool Current version: 8.2.20211222191353