OpenJobDescription / openjd-model-for-python

Provides a Python implementation of the data model for Open Job Description's template schemas.
https://github.com/OpenJobDescription/openjd-specifications/wiki
Apache License 2.0
12 stars 7 forks source link

Bug: Incorrect breadcrumbs in job validation #130

Open ddneilson opened 2 months ago

ddneilson commented 2 months ago

Expected Behaviour

The breadcrumb should direct the user to the correct location within the job template that they should be looking to correct the error.

The breadcrumb:

steps[0] -> steps[0] -> parameterSpace -> steps[0] -> parameterSpace -> steps[0] -> parameterSpace -> taskParameterDefinitions[0] -> range:

should just be:

steps[0] -> parameterSpace -> taskParameterDefinitions[0] -> range:

Current Behaviour

The validation that is happening after job instantiation (i.e. after job parameters have been evaluated for instantiation) is reporting an incorrect breadcrumb for errors in task parameter range expressions.

Reproduction Steps

Given:

specificationVersion: jobtemplate-2023-09
name: BadRangeExpr
parameterDefinitions:
  - name: V
    type: STRING
    default: "1-10:2;10"
steps:
  - name: Test
    parameterSpace:
      taskParameterDefinitions:
        - name: P
          type: INT
          range: "{{Param.V}}"
    script:
      actions:
        onRun:
          command: bash
          args:
          - "-c"
          - "echo 'Hi'"

Run

% openjd run --step Test expr.template.yaml 
ERROR generating Job: Could not generate Job from template and parameters: 1 validation errors for JobTemplate
steps[0] -> steps[0] -> parameterSpace -> steps[0] -> parameterSpace -> steps[0] -> parameterSpace -> taskParameterDefinitions[0] -> range:
    Unexpected ';' in '1-10:2;10' after '1-10:2'

Code Snippet

See the reproduction steps. The likely place that this error is coming from is in the instantiate_model method here.