Skip to content

kcl vet should write a place where required attribute is missing #1845

@alx72n

Description

@alx72n

Feature Request

Environment

kcl: 0.11.0
OS: macOS 15.2

Is your feature request related to a problem? Please describe

Look at this example.

file.yml:

---
items:
  - key: a
    value: 1
  - key: b
  - key: c
    value: 3

file.schema.k:

schema file:
    items: [item]

schema item:
    key: str
    value: int

Validation error:

kcl vet --format=yaml file.yml file.schema.k
EvaluationError
 --> file.schema.k:6:1
  |
6 |     value: int
  |  attribute 'value' of item is required and can't be None or Undefined
  |

The problem appears when file.yml is big enough and contains hundreds of values, there is no easy way to find the exact place where the validation fails to fix the issue (either add missing item or make it optional).

Describe the feature you'd like

I would like the command to show (or stop maybe) at the place where the required fields are missing. Just like similar issue #253.

The desired output of above example:

kcl vet --format=yaml file.yml file.schema.k
EvaluationError
 --> file.yml:5:5
  |
2 |     items:
  | ...
5 |       - key: b
  |         ^ attribute 'value' of item is required and can't be None or Undefined

Violation rule is
 --> file.schema.k:6:5
  | ...
4 | schema item:
  | ...
6 |     value: int
  |      ^ attribute 'value' of item is required and can't be None or Undefined

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions