Skip to content

Conversation

@XN137
Copy link
Contributor

@XN137 XN137 commented Oct 14, 2025

this simplifies frequent usage of the lower level loadEntity api (similar to the
existing findPrincipalByName helper)

@github-project-automation github-project-automation bot moved this to PRs In Progress in Basic Kanban Board Oct 14, 2025
@XN137 XN137 force-pushed the findPrincipalById branch from 12d7889 to 3fb8c4c Compare October 15, 2025 07:17
@XN137 XN137 marked this pull request as ready for review October 15, 2025 07:44
return findPrincipalByName(polarisCallContext, PolarisEntityConstants.getRootPrincipalName());
}

default Optional<PrincipalEntity> findPrincipalById(
Copy link
Contributor

Choose a reason for hiding this comment

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

Having this helper method in principle SGTM. However, given that PolarisMetaStoreManager is one of the main plugin / integrations points, I'm not sure about expanding its API surface with one more method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why do you think its expanding the API surface?
its implementation is just reusing existing methods but encodes more information about the proper way to use them and about the type of entity they will return.
also simplifying code around "exception" handling.

these defaults methods probably never need to be re-implemented by actual classes.

Copy link
Contributor

Choose a reason for hiding this comment

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

It gives callers two options: 1) use the old method 2) use the helper methods... In my mind that expands the API.

I'm thinking that adding methods like this is probably an indication that we may need to rework the interface as a whole.

This is more of a point for thinking about, not an objection, really.

dimas-b
dimas-b previously approved these changes Oct 15, 2025
Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Code change LGTM 👍

Given that we already have other find* method in the metastore manager interface, this PR is probably fine to merge.

In general, I think we need to resume work on untangling different API concerns currently mixed in PolarisMetaStoreManager.

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Oct 15, 2025
@XN137
Copy link
Contributor Author

XN137 commented Oct 16, 2025

I think we need to resume work on untangling different API concerns currently mixed in PolarisMetaStoreManager

in what way is looking up a principal a different api concern in this case?

@dimas-b
Copy link
Contributor

dimas-b commented Oct 16, 2025

in what way is looking up a principal a different api concern in this case?

Principal is an Entity, but has dedicated access methods that are not applicable to other entities.

PrincipalEntity newPrincipal =
metaStoreManager
.findPrincipalById(getCurrentPolarisContext(), currentPrincipalEntity.getId())
.orElseThrow();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we supposed to throw here? If yes, can we make the error message a bit more specific?
No value present --> Failed to find the principal by id: {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i've added a commit to provide a more detailed error message.

however looking at the code in the beginning we do:

PrincipalEntity currentPrincipalEntity = getPrincipalByName(resolutionManifest, principalName);

which would fail hard if the principal did not exist.
and then in rotatePrincipalSecrets we are updating the principal behind currentPrincipalEntity.getId().

so we can be quite sure that another call to findPrincipalById will return a non-empty result.
only if someone externally was dropping the principal with precise timing could we hit this scenario and the old code would have resulted in an NPE in this case.

on that note, seems like all callers of rotatePrincipalSecrets are looking up the updated principal afterwards... makes me wonder whether the method should just return it directly (it loads it already internally).

Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the change, @XN137 ! LGTM overall. Left one minor comments.

XN137 added 2 commits October 17, 2025 09:35
this simplifies frequent usage of the lower level `loadEntity` api (similar to the
existing `findPrincipalByName` helper)
@dimas-b dimas-b merged commit 3c5dbaf into apache:main Oct 17, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Oct 17, 2025
@XN137 XN137 deleted the findPrincipalById branch October 17, 2025 17:41
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.

3 participants