Skip to content

Commit

Permalink
fix app open when multiple app providers are present (#2118)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek authored Oct 4, 2021
1 parent a3ba4a0 commit 4b473fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/app-registry-multiple-providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix app open when multiple app providers are present

We've fixed the gateway behavior, that when multiple app providers are present, it always returned that we have duplicate names for app providers.
This was due the call to GetAllProviders() without any subsequent filtering by name. Now this filter mechanism is in place and the duplicate app providers error will only appear if a real duplicate is found.

https://github.com/cs3org/reva/issues/2095
https://github.com/cs3org/reva/pull/2117
18 changes: 11 additions & 7 deletions internal/grpc/services/gateway/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,19 @@ func (s *svc) findAppProvider(ctx context.Context, ri *storageprovider.ResourceI
return nil, errtypes.InternalError("gateway: error finding app providers")
}

// if we only have one app provider we verify that it matches the requested app name
if len(res.Providers) == 1 {
p := res.Providers[0]
// as long as the above mentioned GetAppProviderByName(app) method is not available
// we need to apply a manual filter
filteredProviders := []*registry.ProviderInfo{}
for _, p := range res.Providers {
if p.Name == app {
return p, nil
filteredProviders = append(filteredProviders, p)
}
// we return error if we return the wrong app provider
err = errtypes.InternalError(fmt.Sprintf("gateway: user asked for app %q and we gave %q", app, p.Name))
return nil, err
}
res.Providers = filteredProviders

// if we only have one app provider we verify that it matches the requested app name
if len(res.Providers) == 1 {
return res.Providers[0], nil
}

// we should never arrive to the point of having more than one
Expand Down

0 comments on commit 4b473fd

Please sign in to comment.