galaxyproject / galaxyproject/gxformat2

Format2 schema accepts documents missing required `class: GalaxyWorkflow` field

Open
#186 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14
Forks
7
Avg merge
2h 49m
Merged PRs (30d)
8

Description

## Problem

`Format2MissingClass` is listed as a schema-decode-enforced rule, but the current pydantic models accept Format2 workflows missing the `class: GalaxyWorkflow` field under both lax and strict validation.

## Repro

```python
from gxformat2.schema.gxformat2 import GalaxyWorkflow as Lax
from gxformat2.schema.gxformat2_strict import GalaxyWorkflow as Strict

wf = {
"inputs": {"x": {"type": "File"}},
"outputs": {"o": {"outputSource": "cat/out_file1"}},
"steps": {"cat": {"tool_id": "cat1", "in": {"input1": "x"}}},
}
Lax.model_validate(wf) # passes
Strict.model_validate(wf) # passes — should fail
```

## Root cause

`gxformat2/schema/gxformat2_strict.py:498` (and `gxformat2.py:482`):

```python
class_: Literal["GalaxyWorkflow"] = Field(default="GalaxyWorkflow", alias="class")
```

The `default=` makes the field optional. The source schema `schema/v19_09/workflow.yml:852` declares `class` as a required enum — no default/null intended.

## Impact

- Schema-rule catalog cannot anchor `Format2MissingClass` with a negative fixture — the rule was dropped from `gxformat2/schema_rules.yml` in the initial landing because negatives pass validation.
- Downstream consumers relying on decode to reject class-less Format2 documents currently get silent acceptance.

## Proposed fix

Remove the `default=` from the generated `class_` field for `GalaxyWorkflow` in both lax and strict models. This likely means adjusting the schema-salad-plus-pydantic codegen (or the source schema annotation) so closed-enum single-symbol fields emit as required `Literal[...]` without a default.

Same concern may apply to `SubworkflowMissingSteps` — nested subworkflow validates with empty/missing `steps`. Worth auditing in the same fix.

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.