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

bug: no pagination header in the Management API response #5926

Closed
2 of 4 tasks
ysemennikov opened this issue May 27, 2024 · 4 comments · Fixed by #5934
Closed
2 of 4 tasks

bug: no pagination header in the Management API response #5926

ysemennikov opened this issue May 27, 2024 · 4 comments · Fixed by #5934
Labels
bug Something isn't working enhancement Make it better

Comments

@ysemennikov
Copy link

ysemennikov commented May 27, 2024

Describe the bug

I use the Management API to retrieve the invitations list of an organization. I use the following endpoint: /api/organization-invitations.

As per the docs, the response is paginated and it must have a Total-Number header. Howewer, in the response there are only these headers:

[
    ("date", "Mon, 27 May 2024 13:11:21 GMT"),
    ("content-type", "application/json; charset=utf-8"),
    ("transfer-encoding", "chunked"),
    ("connection", "keep-alive"),
    ("cross-origin-embedder-policy", "credentialless"),
    ("cross-origin-resource-policy", "same-origin"),
    ("etag", 'W/"11c-r0y5T0M4VeiYnKDsTj/ktBqOlp0"'),
    ("logto-core-request-id", "MEbMPx9Qq82afPuq"),
    ("origin-agent-cluster", "?1"),
    ("referrer-policy", "strict-origin-when-cross-origin"),
    ("strict-transport-security", "max-age=15552000; includeSubDomains"),
    ("vary", "Accept-Encoding"),
    ("vary", "Accept-Encoding, Origin"),
    ("x-content-type-options", "nosniff"),
    ("x-download-options", "noopen"),
    ("x-frame-options", "SAMEORIGIN"),
    ("x-permitted-cross-domain-policies", "none"),
    ("x-xss-protection", "0"),
    ("nel", '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'),
    ("server", "cloudflare"),
    ("content-encoding", "gzip"),
    ("alt-svc", 'h3=":443"; ma=86400'),
]

So neither Total-Number nor Link headers are presented. I've also tried the /api/users/{user_id}/organizations (response also has to be paginated), but no pagination headers are presented.

Please notice in reality there is only 1 invitation and only 1 user in the organization, maybe it makes sense.

Expected behavior

Both Total-Number and Link headers are presented in paginated responses.

How to reproduce?

Send a request to the Logto Management API using the M2M Access Token. Endpoint: /api/organization-invitations or /api/users/{user_id}/organizations

I use Python and the httpx package to send requests to the Management API. The logto-core-request-id header is presented, so I assume headers are not blocked.

The function:

from httpx import AsyncClient

async def get_invitations(
        organization_id: str
    ) -> None:
        """Get all invitations for an organization."""
        async with AsyncClient(base_url="https://<my-logto-endpoint>", headers={"Authorization": "Bearer <token>"}) as client:
            response = await client.get(
                "/api/organization-invitations",
                params={
                    "organizationId": organization_id,
                    "page": 1,
                    "page_size": 50,
                },
            )

        print(response.headers)

Context

  • Logto Cloud
  • Self-hosted, Logto version = 1.16.0
    • Container (Docker image)
    • Raw Node.js
@ysemennikov ysemennikov added the bug Something isn't working label May 27, 2024
@charIeszhao
Copy link
Member

Yes, this is an acknowledged issue. Previously we use this internally for the Cloud collaboration feature, and we assume there won't be too many invitations for a single tenant, and thus the pagination headers were not included.

However, we can improve this in the future releases, but due to the limited bandwidth we can't guarantee when it will happen.

You are always welcome to contribute if you are interested in. Let me know if you need any help.

@charIeszhao charIeszhao added the enhancement Make it better label May 28, 2024
@charIeszhao
Copy link
Member

For now, I'll remove the "invitation list with pagination" description from the API doc, in order not to cause any more confusion.

@ysemennikov
Copy link
Author

Yes, this is an acknowledged issue. Previously we use this internally for the Cloud collaboration feature, and we assume there won't be too many invitations for a single tenant, and thus the pagination headers were not included.

Hey @charIeszhao, thank you for the response!

Is it right that these responses are not paginated now, so I simply get all the invitations that exist? Or they are still paginated, but headers are not being returned?

@charIeszhao
Copy link
Member

You're right. They are not paginated now. Just get all invitations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Make it better
Development

Successfully merging a pull request may close this issue.

2 participants