Skip to content

Conversation

@Tejas-Kochar
Copy link

@Tejas-Kochar Tejas-Kochar commented Dec 18, 2025

Summary

The Java SDK already had support for custom scopes in all three OAuth flows. It only lacked support for configuring scopes in a config file. This PR covers that gap.

Testing

Tested by loading configurations from a test config file and resolving them.


NO_CHANGELOG=true

@github-actions
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 581
  • Commit SHA: 30e93a3c15c1d3551d3c7b2987a6c5bffa2e2c18

Checks will be approved automatically on success.

@Tejas-Kochar Tejas-Kochar changed the title Custom Scopes Support Support for parsing custom scopes in config file Dec 22, 2025
@ConfigAttribute(env = "DATABRICKS_CLIENT_SECRET", auth = "oauth", sensitive = true)
private String clientSecret;

@ConfigAttribute(env = "DATABRICKS_SCOPES", auth = "oauth")
Copy link
Author

Choose a reason for hiding this comment

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

It actually wasn't possible to pass scopes through environment variable because Lists weren't parsed correctly, so removing this is not a breaking change.
Removing the environment variable attribute for consistency with the other SDKs where we are not supporting setting scopes via environment variables.

Comment on lines -39 to 40

@ConfigAttribute(env = "DATABRICKS_SCOPES", auth = "oauth")
@ConfigAttribute(auth = "oauth")
private List<String> scopes;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a backward-incompatible change. What's the rationale for removing this environment variable?

ParameterizedType paramType = (ParameterizedType) field.getGenericType();
if (paramType.getActualTypeArguments().length > 0
&& paramType.getActualTypeArguments()[0] == String.class) {
// Split by commas and/or whitespace and filter out empty strings
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have two delimiters? Shouldn't we only have a single delimiter, preferably a comma?


public String getAsString(Object value) {
if (value instanceof List) {
return String.join(" ", (List<String>) value);
Copy link
Contributor

Choose a reason for hiding this comment

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

You check the instanceof with just List, however, you typecast the variable to List , I think it can lead to unexpected behaviors.


public String getAsString(Object value) {
if (value instanceof List) {
return String.join(" ", (List<String>) value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, why did you choose a space as a delimiter instead of a comma?

field.set(cfg, ProxyConfig.ProxyAuthType.valueOf(value));
} else if (List.class.isAssignableFrom(field.getType())) {
// Handle List<String> fields (e.g., scopes)
// Parse comma and/or whitespace separated values from environment variable or config file
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Parse comma and/or whitespace separated values from environment variable or config file
// Parse comma and/or whitespace separated values from environment variable or config file.

Comment on lines +216 to +217
/** Sort scopes in-place for better de-duplication in the refresh token cache. */
private void sortScopes() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a private function, so according to Java convention. We shouldn't have the comments in the javadoc format.

Suggested change
/** Sort scopes in-place for better de-duplication in the refresh token cache. */
private void sortScopes() {
// Sort scopes in-place for better de-duplication in the refresh token cache.
private void sortScopes() {

Comment on lines +331 to +333
// Config File Scope Parsing Tests

private static Stream<Arguments> provideConfigFileScopesTestCases() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Config File Scope Parsing Tests
private static Stream<Arguments> provideConfigFileScopesTestCases() {
// Config File Scope Parsing Tests.
private static Stream<Arguments> provideConfigFileScopesTestCases() {

Comment on lines +360 to +363
assertEquals(expectedScopes.size(), scopes.size());
for (int i = 0; i < expectedScopes.size(); i++) {
assertEquals(expectedScopes.get(i), scopes.get(i));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a direct comparison, like: assertEquals(expectedScopes, config.getScopes())? Instead of the comparison, you are doing? It seems a bit verbose.

Comment on lines 67 to +71
field.set(cfg, seconds > 0 ? Duration.ofSeconds(seconds) : null);
} else if (field.getType() == ProxyConfig.ProxyAuthType.class) {
field.set(cfg, ProxyConfig.ProxyAuthType.valueOf(value));
} else if (List.class.isAssignableFrom(field.getType())) {
// Handle List<String> fields (e.g., scopes)
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a question about this big if-else block. This block doesn't have a default else, which throws an error when an unexpected type appears in the config. So is the current code simply ignoring those types?

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 this pull request may close these issues.

3 participants