Skip to content

Panic on unexpected schema validation error #265

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 1 commit into from
Sep 1, 2021
Merged

Panic on unexpected schema validation error #265

merged 1 commit into from
Sep 1, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Sep 1, 2021

The err return value of *jsonschema.Schema.ValidateInterface() is used to pass the schema validation failure result.
That error type is given special treatment by Arduino Lint because it occurs under normal circumstances when a rule
violation occurs, and must be interpreted by the rule functions, or even ignored, depending on the tool configuration.

The err return value of *jsonschema.Schema.ValidateInterface() is also used to return errors that indicate some
unexpected problem has occurred separate from a schema validation failure. Previously, these other error types were
ignored and the validation treated as if it had passed, even though it likely never even ran.

Since Arduino Lint controls both the instance and schema data, such these true errors returned by the validation process
should not ever occur when the application is operating correctly. For this reason, a panic is triggered immediately.

The `err` return value of `*jsonschema.Schema.ValidateInterface()` is used to pass the schema validation failure result.
That error type is given special treatment by Arduino Lint because it occurs under normal circumstances when a rule
violation occurs, and must be interpreted by the rule functions, or even ignored, depending on the tool configuration.

The `err` return value of `*jsonschema.Schema.ValidateInterface()` is also used to return errors that indicate some
unexpected problem has occurred separate from a schema validation failure. Previously, these other error types were
ignored and the validation treated as if it had passed, even though it likely never even ran.

Since Arduino Lint controls both the instance and schema data, such these true errors returned by the validation process
should not ever occur when the application is operating correctly. For this reason, a panic is triggered immediately.
@per1234 per1234 added type: bug topic: code Related to content of the project itself labels Sep 1, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #265 (31c699b) into main (1af853e) will decrease coverage by 0.16%.
The diff coverage is 83.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #265      +/-   ##
==========================================
- Coverage   89.83%   89.67%   -0.17%     
==========================================
  Files          43       44       +1     
  Lines        6327     6497     +170     
==========================================
+ Hits         5684     5826     +142     
- Misses        531      549      +18     
- Partials      112      122      +10     
Flag Coverage Δ
unit 89.67% <83.72%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ternal/rule/ruleconfiguration/ruleconfiguration.go 100.00% <ø> (ø)
internal/rule/rulefunction/platform.go 96.65% <ø> (ø)
internal/rule/schema/schema.go 88.88% <71.42%> (-1.54%) ⬇️
ruledocsgen/main.go 83.95% <83.95%> (ø)
internal/result/result.go 91.44% <100.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4c8fdc...31c699b. Read the comment docs.

@per1234 per1234 merged commit 4e6c832 into arduino:main Sep 1, 2021
@per1234 per1234 deleted the schema-validation-error-handling branch September 1, 2021 09:42
@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
@per1234 per1234 self-assigned this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants