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

feat: resource groups and domain endpoints #469

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CristhianF7
Copy link
Contributor

@CristhianF7 CristhianF7 commented Nov 18, 2024

Description

  • Resource groups and domain endpoints

⚠️ still working on unit-test

internal/router/api/v1/domain.go Outdated Show resolved Hide resolved
Copy link
Member

@patrickdappollonio patrickdappollonio left a comment

Choose a reason for hiding this comment

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

Leaving you some food for thought. Nothing that needs to be fixed right now, because those are everywhere in the API anyways.

Comment on lines 133 to 144
azureClient, err := azure.NewClient(
domainListRequest.AzureAuth.ClientID,
domainListRequest.AzureAuth.ClientSecret,
domainListRequest.AzureAuth.SubscriptionID,
domainListRequest.AzureAuth.TenantID,
)
if err != nil {
c.JSON(http.StatusBadRequest, types.JSONFailureResponse{
Message: err.Error(),
})
return
}
Copy link
Member

Choose a reason for hiding this comment

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

No need to fix it right now but food for thought for the future...

The code that validates parameters makes sense it would return a HTTP Bad Request response whenever an error there occurs.

This code though makes no sense returning http.StatusBadRequest. This is an error that after you validated the parameters were there, that you simply couldn't create an Azure client. The error code would probably be some sort of authentication failure or, to avoid disclosing credential details, an Internal Server Error would probably be best!

Comment on lines 146 to 152
domains, err := azureClient.GetDNSDomains(context.Background(), domainListRequest.ResourceGroup)
if err != nil {
c.JSON(http.StatusBadRequest, types.JSONFailureResponse{
Message: err.Error(),
})
return
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here, if you think about it, the data the client sent you was already "validated" at the top. Reaching here post validation to be told that you couldn't load DNS domains seems wrong to, at the same time, return http.StatusBadRequest.

The whole idea of having a REST API is that the API should have a "representational state transfer" (or REST xD) and it's a bad representation that every single error is attributed to the user in the sense that they made a bad request. Talk about gaslighting! 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants