Skip to content

Core: Drop redundant getOperation() overrides in AuthorizationIntent records - #5507

Merged
dimas-b merged 2 commits into
apache:mainfrom
ZephyrYWZhou:refactor-intent-operation-accessor
Sep 16, 2026
Merged

dimas-b merged 2 commits into
apache:mainfrom
ZephyrYWZhou:refactor-intent-operation-accessor

Conversation

@ZephyrYWZhou

Copy link
Copy Markdown
Contributor

Summary

AuthorizationIntent.getOperation() is a bean-style getter, but every implementer is a record with an operation component whose generated accessor is operation(). Because the names don't match, each of the seven records has to add a getOperation() override that just returns operation.

Renaming the interface method to operation() lets the generated accessor satisfy the interface, so those overrides go away. It also lines up with the sibling records that already use canonical accessors (AuthorizationRequest.principal()/intents(), ResolvedIntent.targets()/secondaries()).

Changes

  • Rename AuthorizationIntent.getOperation() to operation().
  • Remove the now-redundant getOperation() override from the seven intent records.
  • Update the call sites in PolarisAuthorizerImpl, RangerPolarisAuthorizer, OpaPolarisAuthorizer, and IcebergCatalogHandlerTest.

Testing

./gradlew :polaris-core:check, plus the Ranger unit tests and intTest, the OPA tests, and the runtime-service catalog handler authz tests. Pure rename, no behavior change.

Checklist

@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Sep 13, 2026
@ZephyrYWZhou
ZephyrYWZhou force-pushed the refactor-intent-operation-accessor branch from f620133 to 95db7f7 Compare September 13, 2026 00:43
@ZephyrYWZhou ZephyrYWZhou changed the title Rename AuthorizationIntent.getOperation() to operation() Core: Drop redundant getOperation() overrides in AuthorizationIntent records Sep 13, 2026
@ZephyrYWZhou
ZephyrYWZhou force-pushed the refactor-intent-operation-accessor branch from 95db7f7 to 3c21ce8 Compare September 13, 2026 05:59

@iprithv iprithv left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we really need this :)

@iprithv iprithv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a complete, behavior-preserving rename (getOperation() → operation()), and the in-tree call sites look covered.

I don't think we need this. The seven record overrides are correct as they are, and this does not fix a bug or change authorization behavior. I'd rather keep the current method name unless there's a stronger reason to churn the PolarAuthorizer input API.

Happy to defer to other reviewers if they want the consistency cleanup.

@ZephyrYWZhou

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and providing your insights @iprithv! And fair point - this is purely a cleanup, with no bug fix or behavior change.

The rationale is consistency plus removing boilerplate: the sibling types in this package already expose their components with canonical record accessors (AuthorizationRequest.principal()/intents(), ResolvedIntent.targets()/secondaries()), so AuthorizationIntent.getOperation() is the only bean-style getter left in the area. Renaming it lets each record's generated operation() accessor satisfy the interface directly, which drops the seven identical override methods.

On the API-churn concern: AuthorizationIntent is a sealed interface with all implementers in-tree, and every call site is updated in this PR, so there are no external implementers to break.

That said, I agree it's a judgment call and not essential. Happy to defer to the authz-area reviewers - @flyrain @sungwy, do you see the consistency/boilerplate cleanup as bringing value to land? I think it's a small but real improvement. I'm equally fine adjusting this if the community consensus is that it's not worth the churn as well.

dimas-b
dimas-b previously approved these changes Sep 14, 2026

@dimas-b dimas-b left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 to this cleanup 👍

AuthorizationIntent is a new class. It is preferable to do cleanup there sooner rather than later.

This kind of change is in-line with the Polaris Evolution policy. Adjustments in downstream caller code are going to be trivial.

My personal view is that the old getOperation name might be an omission WRT to impl-level operation names rather than a deliberate "intent".

@sungwy : WDYT?

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Sep 14, 2026
@dimas-b
dimas-b requested a review from sungwy September 14, 2026 16:08
@dimas-b

dimas-b commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

FYI: @gracechen09

@ZephyrYWZhou

Copy link
Copy Markdown
Contributor Author

Thanks @dimas-b for the review and approval!

@nandorKollar

Copy link
Copy Markdown
Contributor

+1, I think refactors like this are also valuable.

nandorKollar
nandorKollar previously approved these changes Sep 15, 2026
@ZephyrYWZhou

Copy link
Copy Markdown
Contributor Author

Thanks @nandorKollar! Appreciate the recognition here.

@flyrain

flyrain commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fix, @ZephyrYWZhou ! I like the cleanup. I understand Evolution policy doesn't enforce binary compatible, but adding a default method now and remove it later doesn't hurt, and it won't break any downstream. WDYT?

  /** @deprecated Since Polaris 1.8; use {@link #operation()} instead. */
  @Deprecated(since = "1.8")
  default @NonNull PolarisAuthorizableOperation getOperation() {
    return operation();
  }

flyrain
flyrain previously approved these changes Sep 16, 2026
…records

Every AuthorizationIntent is a record with an operation component, so its generated accessor is operation() and each record had to add a getOperation() override that just forwarded to it. Renaming the interface method to operation() lets the generated accessor implement it directly, and lines up with the sibling records (AuthorizationRequest, ResolvedIntent) that already use canonical accessors. Pure rename, no behavior change.

Fixes apache#5506
@ZephyrYWZhou
ZephyrYWZhou dismissed stale reviews from flyrain, nandorKollar, and dimas-b via 4c6965c September 16, 2026 01:24
@ZephyrYWZhou
ZephyrYWZhou force-pushed the refactor-intent-operation-accessor branch from 3c21ce8 to 4c6965c Compare September 16, 2026 01:24
@ZephyrYWZhou

Copy link
Copy Markdown
Contributor Author

Thanks @flyrain! Makes sense - a deprecated default keeps downstream callers of getOperation() working while steering to operation(). Just added that.

Feel free to take a look and help merge if everything looks good.

flyrain
flyrain previously approved these changes Sep 16, 2026

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 Thanks @ZephyrYWZhou !

@flyrain

flyrain commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

@iprithv , would you mind taking another look?

nandorKollar
nandorKollar previously approved these changes Sep 16, 2026
@iprithv

iprithv commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

I was mainly worried about churning the PolarAuthorizer input API for a consistency cleanup. The deprecated getOperation() default covers that, and the consensus here is clear enough that this is worth doing while the type is still new.

LGTM 🚢

@dimas-b

dimas-b commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

adding a default method now and remove it later doesn't hurt, and it won't break any downstream.

That is possible. However, from my POV downstream Authorizer implementations already have to make adjustments due to the SPI migration to "intent-based" parameters. The getOperation() rename overhead is negligible on top of that.

If we keep getOperation() as a deprecated method, please use for removal in the annotation.

Per review feedback, add forRemoval = true to the @deprecated
getOperation() default so it is clearly slated for removal in a
future release.
@ZephyrYWZhou
ZephyrYWZhou dismissed stale reviews from nandorKollar and flyrain via f3dce87 September 16, 2026 16:42
@ZephyrYWZhou

Copy link
Copy Markdown
Contributor Author

Sounds good @dimas-b, just added forRemoval = true to the @Deprecated annotation.

@dimas-b
dimas-b enabled auto-merge (squash) September 16, 2026 17:19
@dimas-b
dimas-b merged commit bcad27d into apache:main Sep 16, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Sep 16, 2026
@ZephyrYWZhou

Copy link
Copy Markdown
Contributor Author

Thanks all for the thoughtful input here! Glad to see we landed on this clean approach eventually🎉! @nandorKollar @dimas-b @iprithv @flyrain.

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.

Drop redundant getOperation() overrides in the AuthorizationIntent records

5 participants