Giter Site home page Giter Site logo

Comments (7)

gabrielsroka avatar gabrielsroka commented on June 18, 2024

@cmc333333 do u have async and await ?

shouldn't it be

async with Client() as client:
    assignment, _, _ = await client.get_application_group_assignment(APP_ID, GROUP_ID)
    # should be a no-op:
    await client.create_application_group_assignment(APP_ID, GROUP_ID, assignment)

from okta-sdk-python.

cmc333333 avatar cmc333333 commented on June 18, 2024

Sorry, yes, please assume there was an await in there. We're converting it all to synchronous versions.

Also, as written, I think the call would error out rather than silently fail (Okta rejects the camelCase version of the field). It looks like both UserProfile and GroupProfile have some logic to account for this problem, so it could just be App profiles that are the problem?

from okta-sdk-python.

gabrielsroka avatar gabrielsroka commented on June 18, 2024

We're converting it all to synchronous versions

how?

It looks like both UserProfile and GroupProfile have some logic to account for this problem

where?

here's my repro code

import okta.client
import asyncio

APP_ID = '0oa...'
GROUP_ID = '00g...'

async def main():
    async with okta.client.Client() as client:
        assignment, _, _ = await client.get_application_group_assignment(APP_ID, GROUP_ID)
        print(assignment.profile)
        await client.create_application_group_assignment(APP_ID, GROUP_ID, assignment)

asyncio.run(main())

i have attributes snake_case and camelCase, but the print shows {'camelCase': 'perl', 'snakeCase': 'python'} (which is wrong)

if i set logging enabled to true, i get

okta-sdk-python - http_client - ERROR - 
{'message': "Okta HTTP 400 E0000001 Api validation failed: Setproperty\nProperty 'snakeCase' not found"}

it sounds like the whole snake_case to camelCase conversion shouldn't be done (not that it should be converted and then converted back again)

from okta-sdk-python.

cmc333333 avatar cmc333333 commented on June 18, 2024

how?

async_to_sync. Not super related to the problem at hand.

where?

# set custom attributes not defined in model, do not change string case
for attr_name in config:
lower_camel_case = to_lower_camel_case(attr_name)
if lower_camel_case not in GroupProfile.BASIC_ATTRIBUTES:
setattr(self, attr_name, config[attr_name])

# set custom attributes not defined in model, do not change string case
for attr_name in config:
lower_camel_case = to_lower_camel_case(attr_name)
if lower_camel_case not in UserProfile.BASIC_ATTRIBUTES:
setattr(self, attr_name, config[attr_name])

I've not dug in enough to understand how that logic's injected, though -- the call to form_response_body is probably before then.

Okta HTTP 400 E0000001

Exactly. I think there are weird edge cases where setting snake_case could override snakeCase and lead to data loss, but the important thing is that the calls aren't doing the "right thing".

it sounds like the whole snake_case to camelCase conversion shouldn't be done

That seems like a fine solution to me! We're working around this by using the response object (second element of the return value) directly.

from okta-sdk-python.

gabrielsroka avatar gabrielsroka commented on June 18, 2024

Not super related to the problem at hand.

yes, and no. i can't repro your code without async and await (i'm not going to use a2s). a2s might have bugs, too. i'd recommend posting code just using the sdk

(i'll take a look at the rest of your response and reply)

from okta-sdk-python.

cmc333333 avatar cmc333333 commented on June 18, 2024

I'm glad you were able to see through my buggy code to the underlying problem.

from okta-sdk-python.

gabrielsroka avatar gabrielsroka commented on June 18, 2024

ooh, i can print(error). i've never done that before

async def main():
    async with okta.client.Client() as client:
        assignment, response, error = await client.get_application_group_assignment(APP_ID, GROUP_ID)
        print(assignment.profile)
        # should be a no-op:
        assignment, response, error = await client.create_application_group_assignment(APP_ID, GROUP_ID, assignment)
        print(error)

i've looked the sdk code. still haven't found anything, but this is promising

MODELS_NOT_TO_CAMEL_CASE = [User, Group, UserSchema, GroupSchema]
next_page, error, next_response = await self.get_next().__anext__()
if error:
return (None, error)
if self._type is not None:
result = []
for item in next_page:
result.append(self._type(item) if self._type in MODELS_NOT_TO_CAMEL_CASE
else self._type(APIClient.form_response_body(item)))

from okta-sdk-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.