Skip to content

fix: use snakeyaml-engine-kmp for validation #281

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

Merged
merged 2 commits into from
Mar 29, 2025

Conversation

Vampire
Copy link
Collaborator

@Vampire Vampire commented Feb 4, 2025

The goal is to have greater control over parsing of the types manifest. kotlinx-serialization-based approach usually communicates about some invalid YAML via exceptions. By going one level down with parsing YAML, we can produce more informative validation errors.

Copy link
Collaborator Author

Vampire commented Feb 4, 2025

Copy link
Collaborator Author

Vampire commented Feb 4, 2025

The output when having a parse error could maybe still be pimped or made nicer to read, but like this could be the switch to SYE for the validation instead of using kaml/KxS :-)

@krzema12
Copy link
Member

krzema12 commented Feb 4, 2025

Wow, cool! I'll review within several days, I want to take it slow.

@Vampire
Copy link
Collaborator Author

Vampire commented Feb 5, 2025

Sure, take your time, just gave it a quick try to see how it goes :-)

Base automatically changed from vampire/use-core-schema to main February 11, 2025 10:40
@Vampire Vampire force-pushed the vampire/use-snakeyaml-engine-kmp-for-validation branch from b356c63 to c5a443a Compare February 12, 2025 10:57
@Vampire Vampire force-pushed the vampire/use-snakeyaml-engine-kmp-for-validation branch from c5a443a to 96adc38 Compare February 12, 2025 16:52
@Vampire Vampire changed the base branch from main to graphite-base/281 February 12, 2025 16:53
@Vampire Vampire changed the base branch from graphite-base/281 to vampire/more-bad-typing-tests February 12, 2025 16:53
@Vampire Vampire force-pushed the vampire/use-snakeyaml-engine-kmp-for-validation branch from 96adc38 to fcb92b8 Compare February 12, 2025 18:13
@Vampire Vampire force-pushed the vampire/more-bad-typing-tests branch from 1bf85e1 to 6f8f4d2 Compare February 12, 2025 18:13
Base automatically changed from vampire/more-bad-typing-tests to main February 15, 2025 21:18
@Vampire Vampire force-pushed the vampire/use-snakeyaml-engine-kmp-for-validation branch 2 times, most recently from 82c37a3 to 090285b Compare February 21, 2025 15:05
@Vampire Vampire force-pushed the vampire/use-snakeyaml-engine-kmp-for-validation branch from 090285b to c3e0823 Compare March 14, 2025 14:58
Comment on lines -15 to -24
#For action with manifest at 'inputs_integer_list_item_with_non_integer_named_value.yml':
#Result:
#\x1B[31m❌ INVALID: Some typing is invalid.\x1B[0m
#
#Inputs:
#• list-of-integer:
# \x1B[31m❌ INVALID: List item type: Named values must be integer.\x1B[0m
#
#Outputs:
#None.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only remaining remark I have for this change is a regression in the level of details for this single case ("named values must be integer"). With the proposed change, the user doesn't know which YAML and which input/output is affected.

However in practice, the lack of details is present in many other cases. I appreciate the fact that checking this type is done together with checking other types, so this PR brings some kind of consistency to the behavior and code structure, even if it introduces a regression in one.

I'm fine with merging it as is, but ideally we should include details about the affected YAML file and input/output in all cases (just articulating it, not saying you should do it). We should rethink if parsing and validation should really be done separately - maybe it's an artificial distinction here, and it's easier to make it in one go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe it can be combined.
I basically kept the changes minimal by replacing the parsing part, only doing some slight improvements on the way and loosing that one type of clarity.
But it can probably be rewritten to provide better errors for all cases, yeah.

@krzema12 krzema12 enabled auto-merge (squash) March 29, 2025 09:22
@krzema12 krzema12 disabled auto-merge March 29, 2025 09:22
@krzema12 krzema12 merged commit be93758 into main Mar 29, 2025
5 checks passed
@krzema12 krzema12 deleted the vampire/use-snakeyaml-engine-kmp-for-validation branch March 29, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants