Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alx72n opened this issue Jan 31, 2025 · 0 comments
Open

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

alx72n opened this issue Jan 31, 2025 · 0 comments
Assignees
Labels
Milestone

Comments

@alx72n
Copy link

alx72n commented Jan 31, 2025

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
@Peefy Peefy added the bug Something isn't working label Feb 4, 2025
@He1pa He1pa added feat and removed bug Something isn't working labels Feb 5, 2025
@zong-zhe zong-zhe added this to the v1.0 Release milestone Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants