-
Notifications
You must be signed in to change notification settings - Fork 688
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
Return NotFound error when decks uri is empty (#642) #6228
Return NotFound error when decks uri is empty (#642) #6228
Conversation
Code Review Agent Run #b1cb17Actionable Suggestions - 3
Review Details
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6228 +/- ##
=======================================
Coverage 36.86% 36.86%
=======================================
Files 1318 1318
Lines 134530 134543 +13
=======================================
+ Hits 49591 49596 +5
- Misses 80619 80626 +7
- Partials 4320 4321 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Changelist by BitoThis pull request implements the following key changes.
|
s, dependencies := setupCreateDownloadLink(t) | ||
dependencies.nodeExecutionManager.EXPECT().GetNodeExecution(mock.Anything, mock.Anything).RunAndReturn(nodeExecutionFunc) | ||
_, err := s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{ |
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.
Consider consolidating the duplicate setup code. The setupCreateDownloadLink()
call appears multiple times in the test function which could be refactored to improve maintainability.
Code suggestion
Check the AI-generated fix before applying
- s, dependencies := setupCreateDownloadLink(t)
- dependencies.nodeExecutionManager.EXPECT().GetNodeExecution(mock.Anything, mock.Anything).RunAndReturn(nodeExecutionFunc)
- _, err := s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{
-
- s, dependencies := setupCreateDownloadLink(t)
- dependencies.dataStore.ComposedProtobufStore.(*commonMocks.TestDataStore).HeadCb = func(ctx context.Context, ref storage.DataReference) (storage.Metadata, error) {
+ setupAndRunTest := func(t *testing.T, setupFn func(*CreateDownloadLinkDependencies)) error {
+ s, dependencies := setupCreateDownloadLink(t)
+ setupFn(dependencies)
+ return s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{})
+ }
Code Review Run #b1cb17
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
|
||
_, err = s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{ | ||
dependencies.nodeExecutionManager.EXPECT().GetNodeExecution(mock.Anything, mock.Anything).RunAndReturn(nodeExecutionFunc) | ||
_, err := s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{ |
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.
Consider declaring err
in the first usage to avoid shadowing. The current declaration of err
shadows the outer scope variable.
Code suggestion
Check the AI-generated fix before applying
_, err := s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{ | |
_, err = s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{ |
Code Review Run #b1cb17
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@@ -179,7 +179,7 @@ func (s Service) CreateDownloadLink(ctx context.Context, req *service.CreateDown | |||
} | |||
|
|||
if len(nativeURL) == 0 { | |||
return nil, errors.NewFlyteAdminErrorf(codes.Internal, "no deckUrl found for request [%+v]", req) | |||
return nil, errors.NewFlyteAdminErrorf(codes.NotFound, "no deckUrl found for request [%+v]", req) |
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.
Consider if changing error code from Internal
to NotFound
is appropriate here. The NotFound
error code should only be used when we're certain the resource doesn't exist. In this case, an empty deckUrl
could indicate an internal system issue rather than a missing resource.
Code suggestion
Check the AI-generated fix before applying
return nil, errors.NewFlyteAdminErrorf(codes.NotFound, "no deckUrl found for request [%+v]", req) | |
return nil, errors.NewFlyteAdminErrorf(codes.Internal, "no deckUrl found for request [%+v]", req) |
Code Review Run #b1cb17
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
A deck url not found in node closure shouldn't result in an internal error and instead should return NotFound grpc code Tested by verifying the UI calls are no longer returning 500 and instead returning 404 Merge the correponding cloud pr and rollout to all managed clusters - [x] To be upstreamed to OSS COR-2803 * [ ] Added tests * [ ] Ran a deploy dry run and shared the terraform plan * [ ] Added logging and metrics * [ ] Updated [dashboards](https://unionai.grafana.net/dashboards) and [alerts](https://unionai.grafana.net/alerting/list) * [ ] Updated documentation Signed-off-by: pmahindrakar-oss <[email protected]>
090c228
to
f80b0dc
Compare
Code Review Agent Run #74578bActionable Suggestions - 0Review Details
|
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
Why are the changes needed?
A deck url not found in node closure shouldn't result in an internal error and instead should return NotFound grpc code
What changes were proposed in this pull request?
Changing the returned grpc code for the API
How was this patch tested?
Tested by verifying the UI calls are no longer returning 500 and instead returning 404
Summary by Bito
The PR implements improved error handling in the data proxy service, changing error codes from Internal to NotFound for missing deck URLs. The test suite underwent significant refactoring with the introduction of CreateDownloadLinkDependencies struct and setup function. Additional test cases were implemented to validate error code behavior for empty deck URLs.Unit tests added: True
Estimated effort to review (1-5, lower is better): 2