-
Notifications
You must be signed in to change notification settings - Fork 0
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
Reworked error output to send IETF RFC-7807 compatible problem responses #14
Conversation
Also fixed indentation
…f/wharf-provider-azuredevops into feature/use-wharf-core-ginutil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jilleJr Makes some good points. After those comments are resolved this has my 👍 .
This also no longer seems like a simple reference swap that the title hints at. I think it would be fair to call it a full rework of error output for the entire repo.
- Sending error responses has mostly been moved from runAzureDevOpsHandler to the functions that it calls instead. - The name of functions that write an error to the gin.Context has the suffix -WritesError. - Added some helpers in the form of extensions of existing code. (Not sure about this decision) - ginutilext, wharfapiext, requests It still feels really messy. I hope I didn't make it worse :&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not review it all, so will have to revisit. But I got a few notes
internal/azure/importer.go
Outdated
i := ImportData{} | ||
err := c.ShouldBindJSON(&i) | ||
if err != nil { | ||
ginutil.WriteInvalidBindError(c, err, | ||
"One or more parameters failed to parse when reading the request body for import details.") | ||
return nil, false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the argument of SRP, then I have some comments:
-
The new
internal/azure
package seems to deal with:- Utility methods to talk to the Azure DevOps API in a type-safe fashion, which should be its own package
- Utility type to use the Azure DevOps API and the Wharf API and transfer data between them, which should be its own package
- Handling and validating of incoming Gin HTTP requests, which should be its own package or live inside the
main
package
-
The
internal/azure/importer.go
file seems to manage:- wharf-provider-azuredevops' incoming JSON structs and how they're serialized (with the
`json:"tokenId"`
attributes), which should live inside themain
package next to the Gin method that accepts that JSON body. - Azure DevOps JSON response models, which should live in the same package (or even file) as the Azure DevOps API wrapper
- wharf-provider-azuredevops' incoming JSON structs and how they're serialized (with the
Would rather see importer.go and client.go live in separate packages
…ient.go and unexported them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked over this again just now and the code still looks nice to me but im having a hard time finding good answers to my usuall questions. Why did we open this PR? What problem does this solve? How do we benefit from solving it?
I can trace this back to vauge mentions of error output and error descriptions. As this PR alone now has 83 comments and its not the only PR that exsists for this goal i think its fair to demand an exlanation of why this is not simple accept&merge ~10 line string change. If this exsits please link it to the PR and in the changelog's change description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per earlier discussion addnig my green check here for neat code. Have not done any analysis on intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Title for 21ff73b is supposed to be Renamed importData -> importBody
.
Closes #13
Depends on iver-wharf/wharf-core#17