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

Incorrect return type #4438

Closed
jaehyi-aws opened this issue Feb 13, 2025 · 4 comments
Closed

Incorrect return type #4438

jaehyi-aws opened this issue Feb 13, 2025 · 4 comments
Assignees
Labels
bug This issue is a confirmed bug. documentation This is a problem with documentation. iam p3 This is a minor priority issue response-requested Waiting on additional information or feedback. service-api This issue is caused by the service API, not the SDK implementation.

Comments

@jaehyi-aws
Copy link

Describe the issue

The documentation for get_account_authorization_details API call specifies an incorrect return type in the response. It says that PolicyDocument is of type string, but it is returned as a dictionary.

Links

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam/client/get_account_authorization_details.html

@jaehyi-aws jaehyi-aws added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Feb 13, 2025
@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Feb 13, 2025
@RyanFitzSimmonsAK RyanFitzSimmonsAK added bug This issue is a confirmed bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. iam p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Feb 13, 2025
@RyanFitzSimmonsAK
Copy link
Contributor

Hi @jaehyi-aws, thanks for reaching out. I was able to reproduce this behavior. I've reached out to the IAM service team to clarify what the intended behavior here and potentially fix the documentation. I'll let you know when I have any updates.

Ticket # for internal use : P200806098

@RyanFitzSimmonsAK RyanFitzSimmonsAK added service-api This issue is caused by the service API, not the SDK implementation. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Feb 13, 2025
@RyanFitzSimmonsAK
Copy link
Contributor

Thanks for your patience. Both the service and the SDK are working as intended here. The API reference for GetAccountAuthorizationDetails has the following note.

Policies returned by this operation are URL-encoded compliant with RFC 3986. You can use a URL decoding method to convert the policy back to plain JSON text. For example, if you use Java, you can use the decode method of the java.net.URLDecoder utility class in the Java SDK. Other languages and SDKs provide similar functionality.

So, the service is returning a string, but because that string is basically unreadable, the SDK does this decoding automatically, and returns it as a dictionary.

https://github.com/boto/botocore/blob/51f1d36c1809357eb6322fdc699d00efe74c0218/botocore/handlers.py#L551

def json_decode_policies(parsed, model, **kwargs):
    # Any time an IAM operation returns a policy document
    # it is a string that is json that has been urlencoded,
    # i.e urlencode(json.dumps(policy_document)).
    # To give users something more useful, we will urldecode
    # this value and json.loads() the result so that they have
    # the policy document as a dictionary.
    output_shape = model.output_shape
    if output_shape is not None:
        _decode_policy_types(parsed, model.output_shape)

The documented return type of PolicyDocument can't be changed, since the model file is correct that the service is returning a string. Please let me know if you have any follow-up questions.

@RyanFitzSimmonsAK RyanFitzSimmonsAK added the response-requested Waiting on additional information or feedback. label Feb 17, 2025
@jaehyi-aws
Copy link
Author

Thanks for the information!

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. documentation This is a problem with documentation. iam p3 This is a minor priority issue response-requested Waiting on additional information or feedback. service-api This issue is caused by the service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants