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

Regression: 404 responses are not handled again #98

Closed
papkos opened this issue Mar 20, 2024 · 3 comments
Closed

Regression: 404 responses are not handled again #98

papkos opened this issue Mar 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@papkos
Copy link

papkos commented Mar 20, 2024

Handling of 404 Not found responses from CommerceTools has a regression: It was not handled properly earlier, fixed at some point, and now it isn't again.

Commit introducing proper handling: 2a3c377
Released in v1.3.0

Commit removing it again: 2463f65#diff-d37bd1a31dfd77757a89090c321d69489ef49983e0270f0a1b82627f3494f854L95 (deep link to a big diff, sorry)

Can you please re-introduce it?


Also, would you consider not including the entire request response in the GenericRequestError? It is potentially leaking resources (open body (IO reader) and maybe more?), and I think the content already contains enough information (can be parsed as other types of errors).

result := GenericRequestError{
	StatusCode: resp.StatusCode,
	Content:    content,
	Response:   resp,
}

Edit: I meant response, not request, sorry

@papkos papkos added bug Something isn't working triage Needs triage labels Mar 20, 2024
@demeyerthom
Copy link
Member

Hi @papkos I will look into this tomorrow!

@demeyerthom demeyerthom removed the triage Needs triage label Mar 20, 2024
@demeyerthom
Copy link
Member

Hi @papkos took some searching, but found that we had generated v1.3.0 with a local copy of the codegen tool where we had made the changes. These however had not been merged back. Did that now, the not found error is restored again: https://github.com/labd/commercetools-go-sdk/releases/tag/v1.5.1

With regards to your second comment: i am not entirely clear what you mean with including the Request? It should be available under GenericRequestError.Response.Request? Or am I missing something:

@papkos
Copy link
Author

papkos commented Mar 27, 2024

Hi, firstly, thanks for the quick fix&release! 🎉

As for this:

With regards to your second comment: i am not entirely clear what you mean with including the Request? It should be available under GenericRequestError.Response.Request? Or am I missing something:

I meant response, not request, sorry.
And I meant not including it in the error struct, because it's quite a heavy object.
Also, it is not an easily serializable struct, because it has functions, IO streams, etc. We discovered this because our error logging failed (we do nest/wrap errors, then we use mapstructure to marshal it into a simple map then JSON for structured logging. The response field made this fail)

Why is it needed/useful? The body/content and the status code is already there, is there some usecase for having the entire response?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants