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: Handle returned error in select.go #1329

Merged
merged 1 commit into from
Apr 11, 2023

Conversation

AndrewSisley
Copy link
Contributor

@AndrewSisley AndrewSisley commented Apr 11, 2023

Relevant issue(s)

Resolves #1264

Description

Handles a previously unhandled returned error path in select.go.

An extra if-else was needed to be added, as commit queries in develop-branch actually depend on the silent ignoring of returned errors.

@AndrewSisley AndrewSisley added bug Something isn't working code quality Related to improving code quality action/no-benchmark Skips the action that runs the benchmark. area/planner Related to the planner system labels Apr 11, 2023
@AndrewSisley AndrewSisley added this to the DefraDB v0.5 milestone Apr 11, 2023
@AndrewSisley AndrewSisley requested a review from a team April 11, 2023 18:08
@AndrewSisley AndrewSisley self-assigned this Apr 11, 2023
@codecov
Copy link

codecov bot commented Apr 11, 2023

Codecov Report

Merging #1329 (b6f14f1) into develop (8ea58ce) will increase coverage by 0.00%.
The diff coverage is 72.72%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1329   +/-   ##
========================================
  Coverage    70.55%   70.56%           
========================================
  Files          184      184           
  Lines        17784    17792    +8     
========================================
+ Hits         12548    12555    +7     
  Misses        4280     4280           
- Partials       956      957    +1     
Impacted Files Coverage Δ
planner/select.go 79.22% <72.72%> (-1.58%) ⬇️

... and 5 files with indirect coverage changes

@jsimnz
Copy link
Member

jsimnz commented Apr 11, 2023

I'm confused by this additional if case, it has a bunch of conditions but is a noop?

@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented Apr 11, 2023

I'm confused by this additional if case, it's has a bunch of conditions but is a noop?

Sorry - I failed to write why that was needed in the description. Basically currently in develop at the moment (and presumably the last few releases), under those conditions we are erroring here (in the else) but ignoring the errors raised (along with any actually useful errors that should be reported).

We cant just return the error (the change to the else), as commit queries with links would stop working, as instead of ignoring the errors we'd report them.

@jsimnz
Copy link
Member

jsimnz commented Apr 11, 2023

This might be problematic, as youve written the if case to be super specific to how the commit.links field is represented (name is links, within a commits select, and not within a collection name. tangentially, its not even clear why you need to check that f.Collection is empty, if youre already checking that its within a commit query).

In the future, as we add other kinds of fields with selection sets (objects) that are system reserved (like links), we'll need more overly specific if branches.

This seems like its caused by the "catchall" else branch, which says if we get here, then the only possible type it could be is a user defined sub type, and we need a typeJoin on it.

So instead of using the complicated noop if branch (which will need to get expanded more and more), why not replace the else with another else if that checks if its a user defined sub-type?

@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented Apr 11, 2023

So instead of using the complicated noop if branch (which will need to get expanded more and more), why not replace the else with another else if that checks if its a user defined sub-type?

How would you write that code? You cant use f.CollectionName, as that inherits from further up the select-chain (required for stuff like aggregates). You also cant use f.Name, as otherwise it will clash with any user-defined links types.

The if-else clause shouldnt get more complex. If other cases get added prior to a rework of this whole function/flow, it should really be another if-else block specific to that case IMO.

I'm also quite adverse to making this too complex right now, atm we are hopefully releasing today, and I want to avoid doing anything too complicated (i.e. risky) in the hours remaining.

@jsimnz
Copy link
Member

jsimnz commented Apr 11, 2023

KK, we can tackle a better else if condition in 0.5.1

Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

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

LGTM

@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented Apr 11, 2023

KK, we can tackle a better else if condition in 0.5.1

I do worry that doing it properly will not be straightforward - I really dont like the select initSource/Fields funcs, and see it almost as a symptom of deficiencies in other parts of the codebase (initFields in particular looks like it should at the very least be handled in planner.go).

At a lower-level I see the need for such a complex if-else as a sign that the mapper model needs improvement.

@AndrewSisley AndrewSisley force-pushed the sisley/fix/I1264-unhandled-select-err branch from a7acb33 to c9393c7 Compare April 11, 2023 19:17
@AndrewSisley AndrewSisley force-pushed the sisley/fix/I1264-unhandled-select-err branch from c9393c7 to b6f14f1 Compare April 11, 2023 19:27
@AndrewSisley AndrewSisley merged commit 0c57c9b into develop Apr 11, 2023
@AndrewSisley AndrewSisley deleted the sisley/fix/I1264-unhandled-select-err branch April 11, 2023 20:00
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/planner Related to the planner system bug Something isn't working code quality Related to improving code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhandled error in planner/select.go
2 participants