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

Cannot create User / Group Attributes with Kotlin SDK if User Attribute is not hidden #544

Closed
frankspeak opened this issue Apr 1, 2021 · 12 comments · Fixed by #601
Closed
Assignees
Labels
kotlin Kotlin SDK issues

Comments

@frankspeak
Copy link

With the Kotlin SDK, running against Looker 7.20.12, user attribute operations fail if the user attribute is not hidden.

For create_user_attribute() for example, this works...

WriteUserAttribute(name=git_password, label=Git Password, type=string, default_value=, value_is_hidden=true, user_can_view=true, user_can_edit=true, hidden_value_domain_whitelist=https://foobar.com/*)

… but this fails with a 422…

WriteUserAttribute(name=git_username, label=Git Username, type=string, default_value=, value_is_hidden=false, user_can_view=true, user_can_edit=true, hidden_value_domain_whitelist=null)

Similiar for set_user_attribute_group_values, this works...

[UserAttributeGroupValue(can=null, id=null, group_id=4, user_attribute_id=38, value_is_hidden=true, rank=null, value=1.2.3.4)]

... but this fails with a 500...

[UserAttributeGroupValue(can=null, id=null, group_id=4, user_attribute_id=28, value_is_hidden=false, rank=null, value=1.2.3.4)]

Testing with the API, I think the issue may be caused by the SDK always sending the hidden_value_domain_whitelist, even if the value is not hidden.

API Docs:

@jkaster jkaster added the kotlin Kotlin SDK issues label Apr 2, 2021
@jkaster
Copy link
Contributor

jkaster commented Apr 2, 2021

Thanks for the report. We'll need to investigate the 422 scenario, and we also never want users to encounter 500 errors from calling our API.

@frankspeak
Copy link
Author

After upgrading to looker 21.0.34, looks like set_user_attribute_group_values() now succeeds - but create_user_attribute() is still failing.

@jkaster
Copy link
Contributor

jkaster commented Apr 16, 2021

Thanks for the update @frankspeak. I should be able to look at this more in the next few days.

@jkaster jkaster self-assigned this Apr 19, 2021
@jkaster
Copy link
Contributor

jkaster commented Apr 19, 2021

The error being obscured in the Kotlin SDK is:

hidden_value_domain_whitelist must be a comma-separated list of urls with optional wildcards, like "https://example.com*,localhost:9932", with bare wildcards not allowed (code: invalid)

@jkaster jkaster closed this as completed Apr 19, 2021
jkaster added a commit that referenced this issue Apr 19, 2021
For diagnosing #544

We have an outstanding feature request to improve analysis of Kotlin SDK errors, but this documents the encountered error in the Typescript SDK test, which has better error handling

API Explorer and the existing Looker API Docs UI can be used to see what the actual 422 error is
@frankspeak
Copy link
Author

@jkaster , not sure I understand - the problem only occurs when the value is not hidden - why is the hidden_domain_whitelist required? Were you able to get this SDK method to work with non-hidden user attributes?

@jkaster
Copy link
Contributor

jkaster commented Apr 19, 2021

Whoops, sorry I forgot to mention an important bit:

When the parameter value_is_hidden=false you do not have to provide the parameter and value for hidden_value_domain_whitelist and the call works as expected.

@frankspeak
Copy link
Author

I'm using the SDK and hidden_value_domain_whitelist is a parameter of WriteUserAttribute.

I tried null, empty strings etc. However, it looks like the SDK always sends it and that's the bug.

As in the description above, if you don't specify it in the web UI, everything works.

@jkaster
Copy link
Contributor

jkaster commented Apr 20, 2021

Reopening because of the Kotlin SDK friction for null properties.

@jkaster jkaster reopened this Apr 20, 2021
jkaster added a commit that referenced this issue Apr 20, 2021
Gson strips `null` properties from the JSON body so create_user_attribute no longer throws an error

Updated test to verify correct behavior and report an error if the call fails

Fixes #544
@jkaster
Copy link
Contributor

jkaster commented Apr 20, 2021

@frankspeak this should definitely be fixed with #601 now. That PR should get merged today

jkaster added a commit that referenced this issue Apr 20, 2021
#601)

* chore: test create_user_attribute

For diagnosing #544

We have an outstanding feature request to improve analysis of Kotlin SDK errors, but this documents the encountered error in the Typescript SDK test, which has better error handling

API Explorer and the existing Looker API Docs UI can be used to see what the actual 422 error is

* fix: Use Gson to serialize Kotlin SDK request bodies

Gson strips `null` properties from the JSON body so create_user_attribute no longer throws an error

Updated test to verify correct behavior and report an error if the call fails

Fixes #544
@jkaster
Copy link
Contributor

jkaster commented Apr 20, 2021

Thanks for your patience and perseverance @frankspeak. Let me know if this doesn't solve the problem for you.

@frankspeak
Copy link
Author

Thanks @jkaster - after the fix, we appear to be in business.

@jkaster
Copy link
Contributor

jkaster commented Apr 21, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kotlin Kotlin SDK issues
Projects
None yet
2 participants