Page the model-services probe past an ACL-emptied first page - #464
Merged
david-siqi-liu merged 7 commits intoSep 2, 2026
Merged
Conversation
`ucode configure`'s model-service probe listed with page_size=1 and judged accessibility from that single page. Unity Catalog applies page_size before ACL filtering, so an early page can return empty with only a next_page_token while accessible model services remain behind the cursor. On the ai-devtools gateway workspace this made configure report "no accessible model services returned; check USE CATALOG ..." even though 42 model services were accessible. Follow the cursor (page_size=50, bounded) before reporting empty, and route a missing-OAuth-scope 403 to the re-login guidance instead of the UC-grant hint, which does not apply to a token-scope failure. Related: ES-2185388 Co-authored-by: Isaac <no-reply@databricks.com>
david-siqi-liu
marked this pull request as ready for review
September 2, 2026 19:48
Only report "no accessible model services" after walking the listing to the end (no pending cursor). A later-page error or hitting the page cap with a cursor still pending is now reachable-but-inconclusive, not empty. Stop treating a model-service scope 403 as globally definitive: the model- service and legacy-endpoint APIs require different OAuth scopes, so attempt the legacy fallback first. Only when the fallback also fails is a missing-scope 403 surfaced, and then as re-login guidance rather than a UC-grant hint. Co-authored-by: Isaac <no-reply@databricks.com>
…uth-only A reachable-but-inconclusive model-service probe (later-page error or page cap) no longer hard-fails as "gateway not enabled" when the legacy fallback is unavailable: the API answered, so it is enabled. GatewayProbe carries an explicit `conclusive` flag to separate "confirmed no accessible resource" from "reachable, unknown", and the coordinator returns the probe in the inconclusive case rather than raising. Scope the missing-scope classifier to the OAuth-token wording so a PAT's permission 403 is not misrouted to OAuth re-login guidance (which cannot fix a PAT) and instead falls through to the grant hint. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
When the model-service probe finds an accessible model service, configure now prints nothing about the gateway and moves on. It emits a single warning line only when no model service was detected but the gateway is still usable (or the result is inconclusive); a hard failure still raises. Drops the success header that would otherwise appear only when something is off. Co-authored-by: Isaac <no-reply@databricks.com>
lilly-luo
reviewed
Sep 2, 2026
Per review: when a model service is accessible, print "Unity AI Gateway connected" as the spinner's success rather than nothing, while still dropping the redundant model-service detail line. The warning path is unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
Collaborator
this error message isn't very user friendly. Can we have it say something like this? Just remove the part about legacy endpoints. OK to do in follow up sine this won't affect Isaac |
lilly-luo
reviewed
Sep 2, 2026
lilly-luo
approved these changes
Sep 2, 2026
Collaborator
Author
I don't think we can remove the part about legacy endpoints, as they are still valid use cases. Otherwise, we should only be probing for v3 and just not use v2. |
david-siqi-liu
enabled auto-merge (squash)
September 2, 2026 21:26
david-siqi-liu
deleted the
david/es-2185388-model-service-probe-pagination
branch
September 2, 2026 21:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What did you change, and why?
ucode configure's model-service probe (_probe_ai_gateway_v3) listed/api/2.1/unity-catalog/model-services?page_size=1and decided accessibility from that single page. Unity Catalog appliespage_sizebefore ACL filtering, so an early page can come back empty with only anext_page_tokenwhile accessible model services remain behind the cursor.On the ai-devtools gateway workspace this made
configureprint:even though the caller had 42 accessible model services and full grants. The hint sent users to fix Unity Catalog permissions that were already correct.
Fix
Page the model-services probe instead of trusting one page.
_probe_ai_gateway_v3now followsnext_page_token(page size 50, bounded by a page cap) and resolves to one of four outcomes, tracked by a newconclusiveflag onGatewayProbe:resource_available;conclusive=False(the listing was not walked to a verdict, so we do not claim it is empty).Don't let an unavailable fallback bury a reachable gateway.
probe_unity_gateway_capabilitiesreturns the reachable-but-inconclusive probe rather than raising "neither endpoint available": the model-services API answered, so the gateway is enabled even though the walk did not finish.Missing-OAuth-scope 403s route to re-login, not to a grant hint — and only after the legacy fallback is attempted, since the model-service and legacy-endpoint APIs require different scopes. The classifier matches the OAuth-token wording specifically, so a PAT's permission 403 (which re-login cannot fix) is not misrouted and instead falls through to the grant guidance.
Trim the happy-path output. When an accessible model service is found,
configurecloses the spinner with✔ Unity AI Gateway connectedand drops the redundant model-service detail line. It prints a single warning line only when no model service was detected but the gateway is still usable (or the result is inconclusive); a hard failure still raises.Also removed the now-unused
empty_hintparameter from_gateway_probe_result.Related: ES-2185388
How do you know it works?
Verified the built probe against three live workspaces:
ai-devtools gateway workspace (the reported case): the probe now resolves to an accessible model service, and
configurecloses the spinner with a success line:CSP-enabled workspace with no model services (v3 reachable but genuinely empty; legacy endpoints disabled for CSP): still hard-fails with an actionable error rather than a false success:
A scope-limited token: probes the legacy fallback first, then returns re-login guidance instead of the UC-grant message.
Tests:
test_databricks.py+test_cli.pypass (538).ruff checkandruff format --checkclean.