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(i): Panic in object equal filter #3143

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

nasdf
Copy link
Member

@nasdf nasdf commented Oct 16, 2024

Relevant issue(s)

Resolves #3141

Description

This PR fixes a bug where the object equality check would panic when comparing with a non object type.

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?

Added integration test.

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

  • MacOS

@nasdf nasdf added bug Something isn't working area/query Related to the query component labels Oct 16, 2024
@nasdf nasdf added this to the DefraDB v0.14 milestone Oct 16, 2024
@nasdf nasdf self-assigned this Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.04%. Comparing base (ba2df4a) to head (d4f4a36).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3143      +/-   ##
===========================================
- Coverage    78.13%   78.04%   -0.09%     
===========================================
  Files          353      353              
  Lines        34647    34647              
===========================================
- Hits         27068    27038      -30     
- Misses        5965     5987      +22     
- Partials      1614     1622       +8     
Flag Coverage Δ
all-tests 78.04% <100.00%> (-0.09%) ⬇️

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

Files with missing lines Coverage Δ
internal/connor/connor.go 100.00% <ø> (ø)
internal/connor/eq.go 91.67% <100.00%> (+5.00%) ⬆️

... and 9 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 ba2df4a...d4f4a36. Read the comment docs.

@nasdf nasdf requested a review from a team October 16, 2024 16:32
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM! Nice simple fix.

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

question: Are you absolutely certain this kind of bug is only present in _eq? Other operators are completely fine?

If so, LGTM :)

d := data.(map[string]any)
if len(d) != len(condition) {
d, ok := data.(map[string]any)
if !ok || len(d) != len(condition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: It would be worth documenting how this can come about, especially given that it was missed originally. Otherwise someone in the future may remove it (and hopefully hit the test, but it will still cost time).

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a developer note to the connor.go header since this will apply to all operators moving forward.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay cheers, I am somewhat sceptical as to whether people will usually read/remember that before reading this line(s), but it saves duplicating the comment in a bunch of places and we can move it inline in the future if people end up tripping up on this.

@nasdf
Copy link
Member Author

nasdf commented Oct 16, 2024

question: Are you absolutely certain this kind of bug is only present in _eq? Other operators are completely fine?

If so, LGTM :)

I'm noticing a few other areas that will have a similar bug. The filters were originally written to be somewhat type safe, but we can't rely on that because the JSON type can be anything.

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.

LGTM

@nasdf nasdf merged commit f528a6b into sourcenetwork:develop Oct 17, 2024
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs with non-coerced JSON value can not be filtered on. Panic.
4 participants