Skip to content

[Server] Configure OPA authorization in the server - #2078

Merged
yili-db merged 15 commits into
unitycatalog:mainfrom
timothyw553:stack/opa-server-config
Nov 11, 2026
Merged

yili-db merged 15 commits into
unitycatalog:mainfrom
timothyw553:stack/opa-server-config

Conversation

@timothyw553

@timothyw553 timothyw553 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


Signed-off-by: Timothy Wang [email protected]

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Make OPA selectable with server.authorization.provider=opa, a decision URL, and a response timeout for each OPA call. Casbin remains the default. Startup rejects OPA with authorization disabled or a missing/invalid decision URL.

Pending OPA calls are cancelled when the UC request is cancelled or times out.

OPA failures now reach callers as HTTP 503 through UC, Iceberg, and Delta error handling. UC database failures keep their UC error codes.

Single authorization checks also preserve UC server error codes (HTTP 5xx) for both Casbin and OPA.

Behavior change for both Casbin and OPA: unexpected errors during list authorization or resource resolution fail the whole request instead of silently omitting affected items. Permission denials and client errors (HTTP 4xx) still filter out individual items.

Add configuration documentation and a runnable Rego example. Native grant/revoke/list APIs continue to manage native records; those grants do not affect OPA decisions. UC still enforces local path and staging-creator checks.

Follow-up: #2177 tracks consistent masking of internal errors in the outer list-filter catch.

Validation:

  • build/sbt javafmtAll.
  • server/testOnly for UnityCatalogServerTest, ServerPropertiesTest, IcebergRestCatalogServiceTest, ResultFilterTest, UnityAccessEvaluatorTest, OpaAuthorizerTest, and SdkOpaAccessControlTest on 6fb1cf5d1: 138 tests passed, none skipped. All four SdkOpaAccessControlTest cases ran against OPA in Docker.

@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from e5c153c to 3794f17 Compare October 29, 2026 22:52
yili-db pushed a commit that referenced this pull request Oct 30, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2076/files) to
review incremental changes.
-
[**stack/auth-resource-types**](#2076)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2076/files)]
← _this PR_
-
[stack/opa-authorizer](#2077)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2077/files/2912ae45366c1a9e3c3b849ac8c78a6e0ad7f7b8..11a01ea1d1964eb1292dc6bc5dabb7786fce7e2d)]
-
[stack/opa-server-config](#2078)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2078/files/11a01ea1d1964eb1292dc6bc5dabb7786fce7e2d..3794f17fbd2e0f69148f9369ed972733fc389fca)]

---------
Signed-off-by: Timothy Wang <[email protected]>

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated (not applicable to this prerequisite; documentation follows in
the integration PR)

**Description of changes**

The evaluator currently drops the resource type before calling the
authorizer. Preserve the resolved `SecurableType` alongside each UUID so
a backend can identify the resource it must authorize.

Pass that type through `authorize`, `authorizeAny`, and `authorizeAll`,
including direct calls from the permission and Iceberg services.
Existing SpEL expressions, null guards, and Casbin decision logic keep
their behavior. There is no REST API change.

Validation: Java formatting and 83 focused server tests passed:

```sh
build/sbt javafmtAll 'server/testOnly io.unitycatalog.server.auth.JCasbinAuthorizerTest io.unitycatalog.server.auth.JCasbinAuthorizerMultiInstanceTest io.unitycatalog.server.auth.decorator.UnityAccessEvaluatorTest io.unitycatalog.server.service.PermissionServiceTest io.unitycatalog.server.service.IcebergRestCatalogServiceTest io.unitycatalog.server.sdk.access.TemporaryPathCredentialAccessControlTest'
```

---------

Signed-off-by: Timothy Wang <[email protected]>
@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch 3 times, most recently from 277eec6 to 17115ea Compare November 3, 2026 19:13
@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from 17115ea to c769110 Compare November 3, 2026 22:33
timothyw553 added a commit that referenced this pull request Nov 3, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2077/files) to
review incremental changes.
-
[stack/auth-resource-types](#2076)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2076/files)]
[MERGED]
-
[**stack/opa-authorizer**](#2077)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2077/files)]
← _this PR_
-
[stack/opa-server-config](#2078)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2078/files/263cd4d4b764f3f32f209c29a3dc9ef9adf73f85..c76911014952bde0835c20721094c002a2c2c75b)]

---------
Signed-off-by: Timothy Wang <[email protected]>

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated (not applicable to this prerequisite; documentation follows in
the integration PR)

**Description of changes**

Add an OPA authorizer that asks about each evaluated privilege, such as
`USE_CATALOG` on a catalog or `CREATE_TABLE` on a schema. UC still
combines the answers through its existing expressions. Any/all checks
preserve their order and short-circuit behavior.

`OpaInputBuilder` reads the user's UUID, email and optional external ID,
plus resource identity and parents. It supports every securable type and
staging tables. No native grants, owner fields, tokens, or cloud
credentials are sent. OPA replies must contain a boolean `result.allow`;
unusable replies and connection failures return a generic `UNAVAILABLE`
error, with no native fallback or decision cache. Missing users,
resources, or parents deny the check without contacting OPA.

Native grant and hierarchy methods delegate to the composed Casbin
authorizer for bookkeeping. Server selection and user documentation
follow in the child PR.

Validation: Java formatting and all 30 backend/metadata tests passed:

```sh
build/sbt javafmtAll 'server/testOnly io.unitycatalog.server.auth.OpaAuthorizerTest io.unitycatalog.server.auth.OpaInputBuilderTest'
```

---------

Signed-off-by: Timothy Wang <[email protected]>
@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from c769110 to f825cd7 Compare November 4, 2026 04:37
@timothyw553
timothyw553 marked this pull request as ready for review November 4, 2026 04:38
@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from 61c4684 to 9de9e92 Compare November 5, 2026 00:14
"server.authorization.provider", "casbin", new EnumValidator(true, "casbin", "opa")),
OPA_DECISION_URL("server.authorization.opa.decision-url", URL_VALIDATOR),
OPA_RESPONSE_TIMEOUT(
"server.authorization.opa.response-timeout", "PT5S", POSITIVE_DURATION_VALIDATOR),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The 5s response timeout bounds each OPA call, but one request can make several calls in a row: authorizeAny/authorizeAll call OPA once per privilege (OpaAuthorizer.java:113-123), so #authorize(#principal, #metastore, OWNER) || #authorizeAny(#principal, #catalog, OWNER, USE_CATALOG) can make three. If OPA answers slowly but inside 5s each time, the request takes ~15s, past Armeria's 10s request timeout. A call that times out fails the request right away, so a hard-down OPA is fine. Would you consider a lower per-call default (Polaris uses PT2S) or a per-request OPA budget, plus a retry with exponential backoff for connection failures inside that budget? I'm adding matching timeouts to the database and cloud clients, so happy to line the values up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the OPA client now cancels pending calls when the UC request times out or is cancelled. added tests for both cases, including checking that later calls never reach OPA. kept the 5s per-call timeout and left retries for separate work.

@yili-db

yili-db commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] No blockers from me. Casbin stays the default, the new properties are additive, and OPA outages fail closed as 503 across the UC, Iceberg and Delta handlers. I checked the CI log and the Docker-backed SdkOpaAccessControlTest really ran (all four methods), not skipped.

Inline: one design question on where the OPA config validation lives, one test that looks redundant, a question on the UNAVAILABLE unwrapping, a follow-up on list-filtering cost, and a nit. Also +1 to @shba24's thread on the per-call timeout vs the request timeout.

* @throws BaseException with {@link ErrorCode#INVALID_ARGUMENT} for a missing URL, an unsupported
* scheme, an invalid host or port, credentials, or a fragment
*/
public String getOpaDecisionUrl() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Can the OPA rules move into validateProperties()? It already hosts the cross-property checks (validateStorageCleanupConfiguration, validateAuthAllowlistConfiguration), so a dedicated validator on OPA_DECISION_URL plus the "opa requires server.authorization=enable" check there would turn this into a plain getter and drop the nullable opaDecisionUrl local in initializeAuthorizer.

Two side effects of the current placement: a bad OPA config fails only after initMetastoreIfNeeded() has written to the DB, and the generic URL_VALIDATOR echoes the raw value (userinfo included) in its message while this getter is careful not to.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

moved the OPA checks into normal property validation and added a dedicated URL validator that keeps credentials out of errors. startup also revalidates before creating resources, since callers can change properties through set(). the getter now just returns the configured value.

HibernateConfigurator hibernateConfigurator,
Repositories repositories) {
String opaDecisionUrl = null;
if (serverProperties.isOpaAuthorizationEnabled()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] See the comment on getOpaDecisionUrl(): if both checks live in ServerProperties.validateProperties(), this block collapses to return isOpaAuthorizationEnabled() ? new OpaAuthorizer(...) : authorizer; inside the existing try.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed the validation block and nullable URL variable. this now just selects the authorizer and logs when OPA is enabled.

}

@Test
public void everyApiReportsAuthorizationUnavailable() throws Exception {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] What does this cover that the existing tests don't? everyApiReportsTheErrorCode right above already renders UNAVAILABLE through all three handlers and asserts the status, and the evaluator unwrapping is already pinned by UnityAccessEvaluatorTest.unavailableDecisionsPropagateWithoutRefresh. I'd drop it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed it and the unused imports. the existing tests already cover the 503 responses and propagation of the original authorization error.

Boolean result = parser.parseExpression(expression).getValue(context, Boolean.class);
return result != null && result;
} catch (SpelEvaluationException e) {
if (e.getCause() instanceof BaseException failure

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Why unwrap only UNAVAILABLE? If the authorizer throws any BaseException, surfacing its code seems better than leaking the SpEL wrapper as a 500. ResultFilter can stay narrow so unknown errors still filter out, but here the rule could be "unwrap any BaseException cause", which also removes the duplicated UNAVAILABLE check between the two classes. Happy to be told the narrow version is deliberate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes, the narrow check is intentional. the OPA path reports failures as UNAVAILABLE. unwrapping other codes would change existing error responses too, so i'd keep that broader change separate.

Comment thread docs/server/auth.md Outdated

An explicit `false` follows UC's normal deny or list-filter behavior. Transport errors, timeouts,
HTTP errors, and missing or invalid decisions fail the UC request with HTTP 503. UC never falls
back to native grants. Decisions are not cached. The response timeout applies to each OPA call;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Not a blocker, but let's follow up. With OPA, list filtering makes one HTTP call per item per privilege, sequentially, all under Armeria's request timeout. "Can require several calls" undersells that for a schema with hundreds of tables. This is #2077's design, but this PR makes it selectable, so a tracking issue for batching decisions (or at least a sentence on how list cost scales) would help. Related to @shba24's timeout thread.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added an explicit note that large lists can still require calls for every item. #2105 already reuses shared-parent decisions within a list, but item-specific checks still make separate OPA calls. batching those calls would be separate work.


@Test
public void opaRequiresAUrlAndReleasesNativeAuthorizerOnClose() {
ServerProperties properties = new ServerProperties(serverProperties);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] nit: the Hikari active-connection count is the only such assertion in the suite. If the intent is "closing the OPA authorizer releases the native one", a spy on JCasbinAuthorizer.close() says that directly without coupling to the Casbin adapter holding exactly one connection.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i kept the connection assertion because it verifies that shutdown returns the connection to the pool while leaving the shared session factory open. a close() spy could pass even if the connection leaked.

@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from 9de9e92 to b576ab1 Compare November 6, 2026 21:40
@timothyw553
timothyw553 requested review from shba24 and yili-db November 6, 2026 22:40
@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

@shba24 shba24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Tim, this looks good to me. Nothing here blocks; the two nits are optional, feel free to take or skip.

I reviewed 7e80047 locally: the formatter check is clean, and the 6 touched test classes pass (121 tests, including the Docker-backed SdkOpaAccessControlTest against a real OPA server). The cancellation in 7e80047 also covers my earlier point about one UC request making several OPA calls in a row.

Nit (not a blocker): PR description. The description doesn't mention that pending OPA calls are cancelled when the UC request is cancelled or times out. docs/server/auth.md already says it, so this is only for reviewers reading the description. How about adding a sentence like this after the first paragraph?

Pending OPA calls are cancelled when the UC request is cancelled or times out.

ctx -> {
ServiceRequestContext root = ctx.root();
if (root != null) {
root.whenRequestCancelling().thenAccept(ctx::cancel);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit (not a blocker): in Armeria 1.41.1, whenRequestCancelling() never completes for a request that succeeds. Its Javadoc says: "If the request is handled successfully without cancellation, the CompletableFuture won't complete." So each OPA call's thenAccept stage, and the client context it captures, stays attached to the root context until the UC request ends. That's bounded by the request (list pages cap at 100 and decisions are cached per request), so I think it's fine as is. I mention it only in case lists get bigger later.

@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from 7e80047 to d7d2cd0 Compare November 6, 2026 23:39
@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

1 similar comment
@yili-db

yili-db commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Thanks for working through the first round. The validation move, the dedicated URL validator, and the cancellation on UC request timeout all look good. On the Hikari assertion: fair argument, a close() spy could pass with a leaked connection, so it stays as is.

One scope note: this PR now also changes list behavior for Casbin users (5xx during list filtering fails the request instead of dropping items). The description mentions it, but can you call it out as its own behavior-change line? The Validation line also lists only ResultFilterTest (2 tests), while the PR touches ServerPropertiesTest, UnityCatalogServerTest, OpaAuthorizerTest, UnityAccessEvaluatorTest, IcebergRestCatalogServiceTest and SdkOpaAccessControlTest. Please list what was actually run.

}
return !authorized;
} catch (Exception e) {
if (e instanceof BaseException failure

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Can we flip this to an allow-list? Filter out only explicit denials and 4xx BaseExceptions, and rethrow everything else.

Today a raw runtime exception still gets filtered. TransactionManager rethrows session-open and begin-transaction failures unwrapped (e.g. pool exhaustion), and KeyMapper hits that path while resolving list items, so the item is dropped and the list returns 200. The docs and description say 5xx during list authorization or resource resolution fails the whole request, which isn't true for these. listFilteringKeepsOtherFailuresAsDenials with IllegalStateException currently locks that in; it would flip to "propagates".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

changed the catch to filter only denials and 4xx UC errors, including those wrapped by SpEL. other failures now fail the request; unexpected exceptions get a generic INTERNAL response so database details aren’t exposed. extended the existing regression tests.

Comment thread docs/server/auth.md Outdated
```

For both Casbin and OPA, server errors (HTTP 5xx) during list authorization or resource
resolution fail the whole request. Previously, affected items could be silently omitted

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] nit: "Previously, ..." is time-relative and will go stale; just state the current behavior. Also this paragraph sits in the middle of the identity-provider setup steps. Can it get its own short heading, or move next to the authorization behavior it describes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed “Previously…” and put the paragraph under a “List authorization” heading. it now states the current behavior for both backends.

@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from 0e76989 to d1e4b10 Compare November 7, 2026 03:14
Use Armeria's cancellation signal to stop OPA HTTP calls when the UC request times out or is cancelled. Verify that later privilege checks send no further OPA requests.

Signed-off-by: Timothy Wang <[email protected]>
Release completed client contexts from UC cancellation callbacks. Preserve UC metadata failures and propagate authorization server errors through list filtering.

Signed-off-by: Timothy Wang <[email protected]>
Add a regression test for server errors while resolving model parents during list filtering. Clarify that error propagation applies to both Casbin and OPA.

Signed-off-by: Timothy Wang <[email protected]>
Filter out explicit denials and UC client errors, including client errors wrapped by expression evaluation. Preserve server error codes and report unexpected failures as INTERNAL with a safe message instead of returning an incomplete list.

Extend the existing regression tests and clarify list behavior for both Casbin and OPA.

Validation: javafmtAll and 155 selected server tests passed, including four tests against a real OPA server. None skipped.
Signed-off-by: Timothy Wang <[email protected]>
@timothyw553
timothyw553 force-pushed the stack/opa-server-config branch from d1e4b10 to ca9f7e3 Compare November 10, 2026 21:25
Preserve explicit HTTP and invalid-decision errors from OPA while keeping authorization failures as UNAVAILABLE. Update existing tests and clarify the Casbin refresh setting and local example policy.

Validation: javafmtAll and all 34 OpaAuthorizerTest and SdkOpaAccessControlTest cases passed, including four tests against OPA in Docker. None skipped.
Signed-off-by: Timothy Wang <[email protected]>
@timothyw553

Copy link
Copy Markdown
Collaborator Author

fixed both in 66c0dc9. explicit OPA errors now keep their specific messages and still return 503. connection failures keep the generic message. also clarified that policy refresh applies only to Casbin. all 34 tests passed, including four against real OPA.

@yili-db

yili-db commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] The validation line in the PR description still says 155 tests and lists ErrorCodeTest, which was removed earlier. Please update it to the run on this head.

return result != null && result;
} catch (SpelEvaluationException e) {
if (e.getCause() instanceof BaseException failure
&& failure.getErrorCode().getHttpStatus().isServerError()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] The evaluator still unwraps every 5xx BaseException, not only UNAVAILABLE. That also changes single #authorize checks for Casbin, and the description does not mention it. No Casbin path throws a 5xx inside SpEL today, and list behavior is already handled in ResultFilter, so narrowing this back to UNAVAILABLE looks sufficient. If you keep the broader rule, please add a line to the description.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added a line to the description clarifying that this also applies to single authorization checks for both Casbin and OPA.

@@ -157,6 +158,14 @@ public <T> void filter(SecurableType securableType, List<T> items, UnaryOperator
iterator.set(result);
}
} catch (Exception e) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Optional future-proofing, since the list path is covered today: this catch rethrows any 5xx BaseException unchanged, so the model-only masking in resolveResourceIdsForItem depends on each source sanitizing its own message. Would it work to mask INTERNAL here once for all list paths, and keep the specific UNAVAILABLE messages from OPA? That would also let us drop the per-call rewrap.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i’d leave the broader masking for a follow-up. the current metadata lookup failure is already masked and tested, so i’m keeping the existing handling here.

@timothyw553

timothyw553 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

The latest AI review found no blockers or "should fix" issues. To keep this PR tightly scoped, I am deferring the following suggestions:

  • The review pointed out that when filtering table/catalog lists, we hide items on any 4xx client error (which technically includes things like 429 rate limits), and asked us to only hide items on specific errors like access denied.

    • Won't do because changing how 4xx errors behave changes existing list-filtering logic across the whole server, and any real OPA failures already return 503 and fail the whole request.
  • The review noticed we unwrap nested exceptions in two different files and asked us to combine them into one shared helper function.

    • Won't do because the two places are checking for different errors (one handles 5xx server errors, the other handles 4xx client errors), and refactoring adds unnecessary churn to an already large PR.
  • The review noticed that checking a list of items attaches a cancellation listener for every single item, and asked us to track them under one shared listener instead.

    • Won't do because each listener already cleans itself up as soon as the item check finishes, so building a custom tracker adds extra concurrency complexity for no real gain.
  • The review asked for a few extra edge-case test combinations, missing Javadocs, and updating an old sentence in AGENTS.md.

    • Won't do because the core functionality is already well tested, and minor doc or test additions are better handled in a small follow-up PR.

All 95 tests are passing, including the four integration tests against live OPA.

@timothyw553

Copy link
Copy Markdown
Collaborator Author

Validation results

updated the validation line to the run on 590820de3: 95 tests passed, none skipped, including all four real OPA tests. it now lists the four classes from that run.

@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Before approval, three items:

(a) Please update the validation line to a run on dc45fb6c that includes UnityCatalogServerTest, ServerPropertiesTest and IcebergRestCatalogServiceTest, which this PR changes. The current line cites 590820de and omits them.

(b) Please open a tracking issue for the broader ResultFilter masking follow-up (masking 5xx errors in the outer catch for all list paths) and link it here.

(c) The "Native permission APIs" paragraph in docs/server/auth.md lists OWNER and READ_METADATA, but PermissionService also accepts MANAGE for the grant-inspection check. Please name MANAGE there too.

@timothyw553

Copy link
Copy Markdown
Collaborator Author

@yili-db
(a) done
(b) done - tracking here: #2177
(c) done.

@yili-db

yili-db commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Thanks for the follow-up. The earlier items are resolved: the validation run covers the three test classes, the masking follow-up is tracked in #2177, and MANAGE is named in the docs.

Non-blocking follow-ups:

  • The validation line still cites 6fb1cf5d1, not the merge head 3564725e. Please refresh the SHA.
  • AGENTS.md, the intro of docs/server/auth.md, and docs/server/helm.md still describe authorization or policy-refresh as Casbin-only. Please add the OPA wording.

@yili-db
yili-db merged commit d5f7859 into unitycatalog:main Nov 11, 2026
23 checks passed
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 12, 2026
…onFolder`

- unitycatalog#2078 added three server builds in `opaCannotRunWithAuthorizationDisabled` and `opaRequiresAUrlAndReleasesNativeAuthorizerOnClose` without one
- Those servers wrote their signing keys, `certs.json` and `token.txt` into `etc/conf`, failing `check_etc_conf.sh`

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 12, 2026
…onFolder`

- unitycatalog#2078 added three server builds in `opaCannotRunWithAuthorizationDisabled` and `opaRequiresAUrlAndReleasesNativeAuthorizerOnClose` without one
- Those servers wrote their signing keys, `certs.json` and `token.txt` into `etc/conf`, failing `check_etc_conf.sh`

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 20, 2026
…onFolder`

- unitycatalog#2078 added three server builds in `opaCannotRunWithAuthorizationDisabled` and `opaRequiresAUrlAndReleasesNativeAuthorizerOnClose` without one
- Those servers wrote their signing keys, `certs.json` and `token.txt` into `etc/conf`, failing `check_etc_conf.sh`

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 21, 2026
…onFolder`

- unitycatalog#2078 added three server builds in `opaCannotRunWithAuthorizationDisabled` and `opaRequiresAUrlAndReleasesNativeAuthorizerOnClose` without one
- Those servers wrote their signing keys, `certs.json` and `token.txt` into `etc/conf`, failing `check_etc_conf.sh`

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 24, 2026
…onFolder`

- unitycatalog#2078 added three server builds in `opaCannotRunWithAuthorizationDisabled` and `opaRequiresAUrlAndReleasesNativeAuthorizerOnClose` without one
- Those servers wrote their signing keys, `certs.json` and `token.txt` into `etc/conf`, failing `check_etc_conf.sh`

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
yili-db added a commit that referenced this pull request Nov 30, 2026
…2167)

## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2167/files) to
review incremental changes.
-
[stack/run_test_followups](#2167)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2167/files)]

---------
- Stop `BaseCredRenewITTest` from starting two servers per test
- Its own `@BeforeEach beforeEach()` called `super.setUp()` after JUnit
had already run the inherited `setUp()`, and the first server was never
closed
  - Override `setUp()` instead
- `BaseServerTest.setUp()` now fails if a server is already running, so
the pattern cannot return silently; `UnityCatalogServerTest` checks that
- Drop `REPLACE_EXISTING` from the signing-key copy, which only
tolerated the second call
- Fail CI when tests write to `etc/conf`
- A server built without its own `configurationFolder` writes its
signing keys, `certs.json` and `token.txt` there; two tests added on
`main` while #2159 was open did exactly that
- `project/scripts/check_etc_conf.sh` fails if any `etc/conf` differs
from the checkout: a new file, ignored or not, or an edited or deleted
tracked one
- `run-uc-unit-tests` runs it after the tests, next to the
clean-checkout step from #2334, which skips ignored files such as the
generated keys; `upgrade-tests.yml` runs it after the upgrade tests
- A fresh CI checkout has only tracked files there, so a local server
cannot cause a false failure
- Give `migrate/TestServer`, used by `RealUpgradeTest` and
`SchemaGateTest`, its own `configurationFolder`
- Give the three server builds in the OPA tests of
`UnityCatalogServerTest` (#2078) their own `configurationFolder`; CI
failed this check on them
- `project/tests/test_check_etc_conf.py`, run in the "Build Test" job,
checks the script in a throwaway git repository, including a deleted
tracked file
- `dev/run-tests.py` watches every `etc/conf` locally, at the root and
in modules up to two levels deep, including hidden files and
subdirectories; `test_run_tests.py` checks it

Tested with `dev/run-tests.py` on `main` at #2357: 240 suites, 3971
tests, 0 failures; afterwards the checkout was clean and
`check_etc_conf.sh` found nothing.
`RealUpgradeTest.upgradesAndKeepsTheData` passed with
`UC_TEST_UPGRADES=true`. With the old `beforeEach()` pattern restored,
every `AwsCredRenewITTest` test fails with the new `setUp()` message.

The test timeout changes that were here moved to #2330.

Signed-off-by: Yi Li <[email protected]>

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

<!-- Please state what you've changed and how it might affect the users.
-->

This pull request and its description were written by Isaac.

---------

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
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