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

feat: allow listing identities by organization ID #4115

Merged
merged 7 commits into from
Oct 28, 2024

Conversation

jonas-jonas
Copy link
Member

Related issue(s)

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got the approval (please contact
    [email protected]) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further Comments

Copy link

codecov bot commented Sep 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.59%. Comparing base (629d867) to head (1795a7a).
Report is 17 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4115      +/-   ##
==========================================
- Coverage   78.61%   78.59%   -0.03%     
==========================================
  Files         378      379       +1     
  Lines       26936    27043     +107     
==========================================
+ Hits        21177    21254      +77     
- Misses       4147     4177      +30     
  Partials     1612     1612              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@hperl hperl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense. I just have one comment regarding parsing the org UUID; and some tests are still missing:

  • Org ID set to a valid UUID: filters
  • Org ID set to an invalid UUID: 400 Bad Request

Not sure what we want to do if the Org ID points to an org that does not exist; but I think the default behaviour (just an empty list of identitites) is fine.

identity/handler.go Show resolved Hide resolved
identity/handler.go Outdated Show resolved Hide resolved
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an index if you make this queryable

@jonas-jonas
Copy link
Member Author

@aeneasr added.

@aeneasr
Copy link
Member

aeneasr commented Sep 23, 2024

@jonas-jonas
Copy link
Member Author

I checked, and the new index doesn't exist yet, so don't think that's the problem

The error also seems unrelated? Any ideas?

   	       ERROR: transaction committed but schema change aborted with error: (23505): failed to ingest index entries during backfill: duplicate key value violates unique constraint "identity_credential_identifiers_identifier_nid_uq_idx" (SQLSTATE XXA00)

@@ -0,0 +1 @@
CREATE INDEX identities_nid_organization_id_idx ON identities (nid, organization_id);
Copy link
Contributor

@alnr alnr Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ... identities (organization_id,created_at);

organization_id is sharded by NID anyway, so we can reduce index size here.

Copy link
Contributor

@alnr alnr Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe (organization_id,id). I thought we sort by created date?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need an index hint here, too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't sort identities by created_at, but the ID string, AFAIK.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying query is getting pretty convoluted, and has a bunch of variations through go if statements. How can we manage that? And make sure that there is an index available for each variation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indices sort their keys anyways, so no need to add id for sorting to the index

@aeneasr aeneasr merged commit b4c453b into master Oct 28, 2024
29 checks passed
@aeneasr aeneasr deleted the jonas-jonas/listIdentitiesByOrgID branch October 28, 2024 09:13
malosayli pushed a commit to nayla-finance/kratos that referenced this pull request Nov 6, 2024
malosayli pushed a commit to nayla-finance/kratos that referenced this pull request Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants