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

Add "Validating attribute values" section to user_doc #54

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

mblsha
Copy link
Contributor

@mblsha mblsha commented Dec 26, 2023

Adapted the discussion thread 1 to document the expected valid key behavior.

Adapted the discussion thread [1] to document the expected `valid` key behavior.

[1]: kaitai-io/kaitai_struct#435
@GreyCat
Copy link
Member

GreyCat commented Dec 26, 2023

Thanks a lot for starting this one! I will add some more, but it's a good clean start.

@GreyCat GreyCat merged commit 95cba36 into kaitai-io:master Dec 26, 2023

When a value does not meet the specified criteria, Kaitai Struct raises a validation error, halting further parsing. This preemptive measure ensures the data being parsed is within the expected domain, providing a first layer of error handling.

NOTE: The actual implementation of validation checks is language-dependent and may vary in behavior and supported features across different target languages.
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why this note is here - it goes against the principles of Kaitai Struct. Once everything is correctly implemented in all target languages (which may with any KS feature temporarily not be the case, but it's simply the reality that individual target languages are in various stages of development at any point in time), the checks will not vary in behavior across different target languages. The status (passed/failed) of any check in one language must be consistent with the status of the same check in the same situation in any other language, any violation is a bug that will be eventually fixed.

@mblsha Did you have something specific in mind when you wrote this sentence? I've just checked the Valid* tests at https://ci.kaitai.io/ and I don't see any current issues with valid, except for Nim, Perl and Construct (all of which are somewhat niche targets), where valid presumably isn't implemented at all, but I don't see any behavior variations.

I remember that valid still doesn't have type checks (kaitai-io/kaitai_struct_formats#678 (comment)), so perhaps you mean the implications of that.

Copy link
Member

Choose a reason for hiding this comment

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

I believe what @mblsha meant here was that exception handling by itself is not a universal mechanism by any stretch, and indeed individual exception names and notation will vary widely between languages. That's at least how I interpreted this. I certainly won't argue that we should also have language-dependent explanations on how these validation exceptions (or error codes, or whatever it will manifest in) work for specific languages.

@mblsha
Copy link
Contributor Author

mblsha commented Dec 26, 2023

@generalmimon should I delete this "NOTE:" from the doc then?

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.

3 participants