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

Return NotFound error when decks uri is empty (#642) #6228

Conversation

pmahindrakar-oss
Copy link
Contributor

@pmahindrakar-oss pmahindrakar-oss commented Feb 6, 2025

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

@pmahindrakar-oss pmahindrakar-oss added the fixed For any bug fixes label Feb 6, 2025
@pmahindrakar-oss pmahindrakar-oss changed the title [COR-2803] Return NotFound error when decks uri is empty (#642) Return NotFound error when decks uri is empty (#642) Feb 6, 2025
@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 6, 2025

Code Review Agent Run #b1cb17

Actionable Suggestions - 3
  • flyteadmin/dataproxy/service_test.go - 2
    • Consider consolidating duplicate test setup code · Line 202-204
    • Variable shadowing in CreateDownloadLink test · Line 300-300
  • flyteadmin/dataproxy/service.go - 1
Review Details
  • Files reviewed - 2 · Commit Range: 090c228..090c228
    • flyteadmin/dataproxy/service.go
    • flyteadmin/dataproxy/service_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.86%. Comparing base (ea00864) to head (f80b0dc).
Report is 6 commits behind head on master.

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     
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 51.94% <100.00%> (+<0.01%) ⬆️
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 62.29% <ø> (ø)
unittests-flyteidl 7.23% <ø> (ø)
unittests-flyteplugins 53.91% <ø> (ø)
unittests-flytepropeller 42.78% <ø> (-0.01%) ⬇️
unittests-flytestdlib 55.33% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 6, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Bug Fix - Error Code Correction for Missing Deck URLs

service.go - Changed error code from Internal to NotFound when deck URL is missing

service_test.go - Refactored test structure and added test case for missing deck URL scenario

Comment on lines +202 to +204
s, dependencies := setupCreateDownloadLink(t)
dependencies.nodeExecutionManager.EXPECT().GetNodeExecution(mock.Anything, mock.Anything).RunAndReturn(nodeExecutionFunc)
_, err := s.CreateDownloadLink(context.Background(), &service.CreateDownloadLinkRequest{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider consolidating duplicate test setup code

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{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Variable shadowing in CreateDownloadLink test

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
Suggested change
_, 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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Error code change may mask issues

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
Suggested change
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]>
@pmahindrakar-oss pmahindrakar-oss force-pushed the union/upstream-c2ba613c57d13ff48cf3aa4d331cd055511c7e17 branch from 090c228 to f80b0dc Compare February 7, 2025 01:44
@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 7, 2025

Code Review Agent Run #74578b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: f80b0dc..f80b0dc
    • flyteadmin/dataproxy/service.go
    • flyteadmin/dataproxy/service_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

Copy link
Member

@Future-Outlier Future-Outlier left a comment

Choose a reason for hiding this comment

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

thank you

@pmahindrakar-oss pmahindrakar-oss merged commit 34205dd into master Feb 7, 2025
53 checks passed
@pmahindrakar-oss pmahindrakar-oss deleted the union/upstream-c2ba613c57d13ff48cf3aa4d331cd055511c7e17 branch February 7, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed For any bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants