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

[ISSUE] listSecrets returns null if no secrets are found in a scope #197

Closed
MichaelJHaywood opened this issue Nov 30, 2023 · 4 comments · Fixed by #266
Closed

[ISSUE] listSecrets returns null if no secrets are found in a scope #197

MichaelJHaywood opened this issue Nov 30, 2023 · 4 comments · Fixed by #266
Assignees

Comments

@MichaelJHaywood
Copy link

Description
If I make a call to get a list of secrets in a scope, it returns null if no secrets are found.

Reproduction
Returns null if no secrets are found

String scopeName = "example";
workspaceClient.secrets().createScope(scopeName );
workspaceClient.secrets().listSecrets(scopeName ); // Returns null

Returns a secret if a secret is found

String scopeName = "example";
workspaceClient.secrets().createScope(scopeName );
workspaceClient.secrets()
          .putSecret(new PutSecret()
                  .setScope(scopeName)
                  .setKey("key")
                  .setStringValue("value")
          );
workspaceClient.secrets().listSecrets(scopeName );  // Successfully returns a secret

Expected behavior
An empty result instead of null.

Is it a regression?
Unknown.

Other Information

  • OS: Windows 10
  • Version: 10.0.19043 Build 19043
@mgyucht
Copy link
Contributor

mgyucht commented Dec 4, 2023

Thanks for reporting this! We'll take a look. Just to confirm, is listSecrets() itself returning null or does the returned iterator return null when calling the next() method?

@MichaelJHaywood
Copy link
Author

@mgyucht I believe I was printing the returned iterable and it was null. It appeared to be behaving differently to other list() calls as I normally convert it to a stream using:

StreamSupport.stream(iterable.spliterator(), false)

but it was failing as it was null.

I can't check right now to be certain sorry!

@MichaelJHaywood
Copy link
Author

@mgyucht
We've had a similar error occur but for clusters. If you get a list of clusters and none are found, it returns null instead of an empty iterable.
The sql warehouse method correctly returns an empty iterable.

@mgyucht
Copy link
Contributor

mgyucht commented Apr 19, 2024

Thanks for this. I've identified the root cause and made a PR to address it: #266.

github-merge-queue bot pushed a commit that referenced this issue Apr 19, 2024
## Changes
Currently, non-paginated list APIs in the Java SDK simply return the
field in the response with the listed items. However, when there are no
items in the collection being listed. This PR changes all list APIs to
return a Paginator so that the API response is never `null`.

Resolves #197.

## Tests
Tested listing clusters using an SP with no access to any clusters,
which passed:
```
10:12 [DEBUG] > GET /api/2.0/clusters/list
< 200 OK
< { }
```
vikrantpuppala pushed a commit to vikrantpuppala/databricks-sdk-java that referenced this issue Apr 23, 2024
## Changes
Currently, non-paginated list APIs in the Java SDK simply return the
field in the response with the listed items. However, when there are no
items in the collection being listed. This PR changes all list APIs to
return a Paginator so that the API response is never `null`.

Resolves databricks#197.

## Tests
Tested listing clusters using an SP with no access to any clusters,
which passed:
```
10:12 [DEBUG] > GET /api/2.0/clusters/list
< 200 OK
< { }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants