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

fix: Add validation to JSON fields #2375

Conversation

fredcarle
Copy link
Collaborator

Relevant issue(s)

Resolves #2370

Description

This PR adds validation to JSON fields.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

make test

Specify the platform(s) on which this was tested:

  • MacOS

@fredcarle fredcarle added the bug Something isn't working label Mar 5, 2024
@fredcarle fredcarle added this to the DefraDB v0.10 milestone Mar 5, 2024
@fredcarle fredcarle requested a review from a team March 5, 2024 17:19
@fredcarle fredcarle self-assigned this Mar 5, 2024
@fredcarle fredcarle force-pushed the fredcarle/fix/i2370-validate-json-field branch from 2f9e4ea to 97f02e8 Compare March 5, 2024 17:20
Copy link
Member

@nasdf nasdf left a comment

Choose a reason for hiding this comment

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

Thanks for fixing! The additional test coverage is nice.

Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 74.99%. Comparing base (eb872f5) to head (97f02e8).

❗ Current head 97f02e8 differs from pull request most recent head f7a6a45. Consider uploading reports for the commit f7a6a45 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2375      +/-   ##
===========================================
- Coverage    75.03%   74.99%   -0.04%     
===========================================
  Files          266      266              
  Lines        25855    25869      +14     
===========================================
  Hits         19400    19400              
- Misses        5150     5161      +11     
- Partials      1305     1308       +3     
Flag Coverage Δ
all-tests 74.99% <80.00%> (-0.04%) ⬇️

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

Files Coverage Δ
client/errors.go 63.93% <100.00%> (+1.22%) ⬆️
client/document.go 70.75% <76.92%> (+0.11%) ⬆️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

custom
}
}`,
ExpectedError: `Argument "input" has invalid value {name: "John", custom: "{\"tree\": \"maple, \"age\": 250}"}.
Copy link
Member

Choose a reason for hiding this comment

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

though: LOL that's a long error 😱

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

NICE!

Praise:

Coverage    74.98%   74.99%   +0.01%

Copy link
Contributor

@islamaliev islamaliev left a comment

Choose a reason for hiding this comment

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

Awesome. Thanks for tests

@fredcarle fredcarle force-pushed the fredcarle/fix/i2370-validate-json-field branch from 97f02e8 to f7a6a45 Compare March 5, 2024 20:57
@fredcarle fredcarle merged commit a195e0f into sourcenetwork:develop Mar 5, 2024
27 of 28 checks passed
@fredcarle fredcarle deleted the fredcarle/fix/i2370-validate-json-field branch March 5, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The content of doc field of type JSON is not validated
4 participants