common-workflow-language / common-workflow-language/schema_salad

schema-salad-tool throws an exception with schemas with a union of enum arrays during document parsing time

Open
#537 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
86
Forks
64
Avg merge
19h 24m
Merged PRs (30d)
19

Description

Although schemas with a union of enum arrays are valid, schema-salad-tool cannot parse documents with such schemas and throws an exception due to the schema rather than the input document.

If it is a bug of schema-salad-tool, I will send a pull request for it.

# Inputs
- enum-arrays.yml
```yaml
$graph:
- name: Enum1
type: enum
symbols: [a]
- name: Enum2
type: enum
symbols: [b]
- name: Test
documentRoot: true
type: record
fields:
field:
type:
- type: array
items: Enum1
- type: array
items: Enum2
```
It is a valid schema as shown in the following command:
```console
$ schema-salad-tool schema_salad/schema_salad/metaschema/metaschema.yml enum-arrays.yml
/home/vscode/.local/bin/schema-salad-tool Current version: 8.2.20220204150214
Document `enum-arrays.yml` is valid
```

Therefore we expect that schema-salad-tool can parse the following document with the above schema:

- doc.yml
```yaml
field: [a]
```

We expect `doc.yml` can be parsed with `enum-arrays.yml`.
```console
$ schema-salad-tool enum-arrays.yml doc.yml
```

# Expected behavior
It succeeds its execution as follows:
```console
$ schema-salad-tool enum-arrays.yml doc.yml
/home/vscode/.local/bin/schema-salad-tool Current version: 8.2.20220204150214
Document `doc.yml` is valid
```

# Actual behavior
It fails validation due to the error of the schema although it is valid:
```console
$ schema-salad-tool enum-arrays.yml doc.yml
/home/vscode/.local/bin/schema-salad-tool Current version: 8.2.20220204150214
Schema `enum-arrays.yml` error:
Union item must be a valid Avro schema: {'name': 'workspaces.cwltest.enum-arrays.yml.Test', 'documentRoot': True, 'type': 'record', 'fields': [{'type': [{'type': 'array', 'items': 'workspaces.cwltest.enum-arrays.yml.Enum1', 'name': ''}, {'type': 'array', 'items': 'workspaces.cwltest.enum-arrays.yml.Enum2', 'name': ''}], 'name': 'field'}]}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.