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

Organizations: list_organizational_units_for_parent #4077

Open
holdcrop opened this issue Apr 8, 2024 · 2 comments
Open

Organizations: list_organizational_units_for_parent #4077

holdcrop opened this issue Apr 8, 2024 · 2 comments
Assignees
Labels
bug This issue is a confirmed bug. organizations p2 This is a standard priority issue pagination

Comments

@holdcrop
Copy link

holdcrop commented Apr 8, 2024

Describe the bug

When calling the list_organizational_units_for_parent operation, there is an inconsistent result returned versus the CLI.

Despite only having a single OU listed under the parent, the results from boto3 need to be paginated in order to retrieve the expected child OU details.

The same call through the CLI requires no pagination.

Expected Behavior

When there are fewer results than the page size limit, pagination should not be required.

Current Behavior

Organization Structure:

  • Root
    | - Parent
    | - - Child

In trying to get the Id of the Child Organization Unit, pagination is required on the list_organizational_units_for_parent operation using the Parent Organisation Unit Id

Reproduction Steps

Organization Structure:

  • Root
    | - Parent
    | - - Child

In trying to get the Id of the Child Organization Unit, pagination is required on the list_organizational_units_for_parent operation using the Parent Organisation Unit Id

Possible Solution

No response

Additional Information/Context

No response

SDK version used

1.34.79

Environment details (OS name and version, etc.)

Amazon Linux 2, Python 3.9

@holdcrop holdcrop added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Apr 8, 2024
@tim-finnigan tim-finnigan self-assigned this Apr 12, 2024
@tim-finnigan tim-finnigan added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 12, 2024
@tim-finnigan
Copy link
Contributor

Hi @holdcrop thanks for reaching out. Have you tried using the ListOrganizationalUnitsForParent paginator?

For example:

import boto3

client = boto3.client('organizations')

paginator = client.get_paginator('list_organizational_units_for_parent')

response_iterator = paginator.paginate(
    ParentId='r-12345',
    PaginationConfig={}
)

for page in response_iterator:
    print(page)

The AWS CLI handles server-side pagination automatically, so it will continue to fetch results when there are more to return. Boto3 paginators enable this behavior as well.

Without automatic pagination the NextToken is required to fetch additional results, as described in the list_organizational_units_for_parent command documentation:

Always check the NextToken response parameter for a null value when calling a List* operation. These operations can occasionally return an empty set of results even when there are more results available. The NextToken response parameter value is null only when there are no more results to display.

@tim-finnigan tim-finnigan added response-requested Waiting on additional information or feedback. pagination organizations p2 This is a standard priority issue and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 12, 2024
@holdcrop
Copy link
Author

Hi @tim-finnigan,
Thanks for coming back on this.
We did use the Paginator to get around this issue. It's just unusual behaviour that with a single OU, there are no results returned without pagination.
I think this was also behaviour that changed. We had this code in use since 2022 (albeit accessed infrequently) and now requires pagination.
Thanks for your time,
@holdcrop

@github-actions github-actions bot removed the response-requested Waiting on additional information or feedback. label Apr 16, 2024
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. organizations p2 This is a standard priority issue pagination
Projects
None yet
Development

No branches or pull requests

2 participants