-
Notifications
You must be signed in to change notification settings - Fork 44
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
v1/internal: refactor GetComposeStatus
improve error handling
#1324
base: main
Are you sure you want to change the base?
Conversation
3e9f6ca
to
1f37e93
Compare
Codecov ReportAttention: Patch coverage is
|
1f37e93
to
17e1d2c
Compare
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.
While this makes the functions smaller and more readable
it duplicates the number of requests (calling h.getComposeByIdAndOrgId(ctx, composeId)
twice now)?
If I'm right - this should be optimized to avoid duplicating the number of external requests
17e1d2c
to
2c6fd00
Compare
2c6fd00
to
7079a25
Compare
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.
Thank you, I'm not familiar with the image-builder codebase so please take my review with a grain of salt. I have some suggestions inline about structure and naming though that are maybe/hopefully helpful :)
httpError := echo.NewHTTPError(http.StatusInternalServerError, "Failed querying compose status") | ||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
ctx.Logger().Errorf("Unable to parse composer's compose response: %v", err) |
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.
I know this is a pre-existing string but it's a bit misleading, here it's not about parse
but about reading.
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.
AFAICT this still an open topic, no? Maybe: ctx.Logger().Errorf("Unable to read error response data: %v", err)
?
7079a25
to
3852b9e
Compare
ab51f06
to
9b4a036
Compare
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.
Thank you and sorry that it took me so long to look at this! This looks nice, some tiny naming/code organisation suggestions inline for your consideration.
8e3471f
to
f55a3b2
Compare
This PR is stale because it has been open 30 days with no activity. Remove "Stale" label or comment or this will be closed in 7 days. |
f55a3b2
to
1c4f770
Compare
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.
Thank you for this refactor, I have two small suggestions inline, but if you prefer we could also do them as a followup (but I included a suggested diff so maybe/hopefully it's not much trouble).
7aa99c1
to
a566c2e
Compare
a566c2e
to
d80a189
Compare
d80a189
to
d2b1746
Compare
…ode structure this commit improve error handling and code structure * Split GetComposeStatus into smaller, more focused functions * Enhance error handling with more specific HTTP status codes *Add dedicated functions for handling different response scenarios * Implement parseAndRedactComposeRequest for better separation of concerns * Improve code readability and maintainability
d2b1746
to
36cf450
Compare
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.
This is nice, thank you! One tiny comment left but everything else looks very nice now
this commit improve error handling and code structure