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

Reworked error output to send IETF RFC-7807 compatible problem responses #14

Merged
merged 38 commits into from
Aug 19, 2021

Conversation

Alexamakans
Copy link
Member

@Alexamakans Alexamakans commented Jun 15, 2021

Closes #13
Depends on iver-wharf/wharf-core#17

@Alexamakans Alexamakans added the enhancement New feature or request label Jun 15, 2021
@Alexamakans Alexamakans self-assigned this Jun 15, 2021
@Alexamakans Alexamakans added this to In progress in Backlog via automation Jun 15, 2021
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
Backlog automation moved this from In progress to Review in progress Jun 15, 2021
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
fredx30
fredx30 previously approved these changes Jun 16, 2021
Copy link
Contributor

@fredx30 fredx30 left a 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 :&
@Alexamakans Alexamakans changed the title Changed to use wharf-core/pkg/ginutil Reworked error output to send IETF RFC-7807 compatible problem responses Jun 22, 2021
Copy link
Contributor

@applejag applejag left a 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

azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
azuredevops.go Outdated Show resolved Hide resolved
helpers/ginutilext/extension.go Outdated Show resolved Hide resolved
helpers/ginutilext/extension.go Outdated Show resolved Hide resolved
helpers/requests/requests.go Outdated Show resolved Hide resolved
helpers/requests/requests.go Outdated Show resolved Hide resolved
helpers/requests/requests.go Outdated Show resolved Hide resolved
helpers/wharfapiext/extension.go Outdated Show resolved Hide resolved
helpers/wharfapiext/extension.go Outdated Show resolved Hide resolved
internal/azure/client.go Outdated Show resolved Hide resolved
internal/azure/client.go Outdated Show resolved Hide resolved
internal/azure/importer.go Outdated Show resolved Hide resolved
pkg/requests/requests.go Outdated Show resolved Hide resolved
pkg/requests/requests.go Outdated Show resolved Hide resolved
pkg/requests/requests.go Outdated Show resolved Hide resolved
Comment on lines 103 to 109
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
}
Copy link
Contributor

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 the main 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

Would rather see importer.go and client.go live in separate packages

Copy link
Contributor

@fredx30 fredx30 left a 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.

@fredx30 fredx30 self-requested a review August 16, 2021 11:55
@fredx30 fredx30 dismissed their stale review August 16, 2021 11:56

Ñeeds link to change description.

Backlog automation moved this from Review in progress to Reviewer approved Aug 17, 2021
Copy link
Contributor

@fredx30 fredx30 left a 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.

Copy link
Member Author

@Alexamakans Alexamakans left a 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.

@Alexamakans Alexamakans merged commit ef5180f into master Aug 19, 2021
Backlog automation moved this from Reviewer approved to Done Aug 19, 2021
@Alexamakans Alexamakans deleted the feature/use-wharf-core-ginutil branch August 19, 2021 06:43
@applejag applejag mentioned this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Use wharf-core/pkg/ginutil for error responses
3 participants