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: Serialize DB errors to json in http package #1401

Merged
merged 3 commits into from
Apr 24, 2023

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #1383

Description

Serializes DB errors to json in http package. They were previously resolving to "{}".

image

@AndrewSisley AndrewSisley added bug Something isn't working area/network Related to internal/external network components action/no-benchmark Skips the action that runs the benchmark. labels Apr 24, 2023
@AndrewSisley AndrewSisley added this to the DefraDB v0.5.1 milestone Apr 24, 2023
@AndrewSisley AndrewSisley requested a review from a team April 24, 2023 17:39
@AndrewSisley AndrewSisley self-assigned this Apr 24, 2023
@AndrewSisley AndrewSisley changed the title fix: Serialize DB errors to json in http package fix: Serialize DB errors to json in http package Apr 24, 2023
@codecov
Copy link

codecov bot commented Apr 24, 2023

Codecov Report

Merging #1401 (ae51915) into develop (e20f364) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1401      +/-   ##
===========================================
+ Coverage    70.71%   70.76%   +0.04%     
===========================================
  Files          184      185       +1     
  Lines        17875    17884       +9     
===========================================
+ Hits         12641    12655      +14     
+ Misses        4282     4279       -3     
+ Partials       952      950       -2     
Impacted Files Coverage Δ
api/http/handlerfuncs.go 77.44% <100.00%> (ø)
api/http/request_result.go 100.00% <100.00%> (ø)

... and 7 files with indirect coverage changes

Comment on lines +23 to +25
for i := range r.Errors {
errors[i] = r.Errors[i].Error()
}
Copy link
Member

Choose a reason for hiding this comment

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

nitpick:

Suggested change
for i := range r.Errors {
errors[i] = r.Errors[i].Error()
}
for i, e := range r.Errors {
errors[i] = e.Error()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I'm happy with either. Leaving as is

) {_key}
}"
}`
// remote line returns and tabulation from formatted statement
Copy link
Member

Choose a reason for hiding this comment

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

typo: Do you mean replace instead of remote?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, this comment is here to indicate that the PR author's brain auto-filtered out the comments and failed to remove it having copy-pasted from the test above.

  • remove?

Test is quite lazy/bad as it doesnt really show that the returned error is just an empty object, but it is very temporary
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

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!

@AndrewSisley AndrewSisley merged commit 27f26b4 into sourcenetwork:develop Apr 24, 2023
12 checks passed
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Add test for http errors

Test is quite lazy/bad as it doesnt really show that the returned error is just an empty object, but it is very temporary

* Serialize db errors to json correctly
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/network Related to internal/external network components bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors dont Marshal nicely to json
3 participants