Repository navigation
[UI] Consolidate RPC handlers and tighten bridge response validation - #2262
Conversation
|
/review |
|
Addressed the AI review in five commits:
|
|
/review |
**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. (No issue; split out of #2262.) - [ ] If you've fixed a bug or added code that should be tested, add tests! (Formatting only; no new behavior.) - [ ] If you've added or modified a feature, documentation in `docs` is updated. (No feature change.) **Description of changes** `bun run test:format` fails on `main`: 39 files under `ui-new/web/src` predate the package's Prettier check. This applies the package's own `bun run format` to them and changes nothing else. Why now: #2262 carried this reformatting alongside its bridge changes, which made 38 of its 51 web files formatting-only. Landing it separately keeps #2262 reviewable; once this merges, #2262 is rebased and those hunks drop out. No behavior change: - Every changed file is exactly Prettier's output of its version on `main` (checked file by file). - No generated files are touched (`src/gen`, `routeTree.gen.ts`). Validation, run locally in `ui-new/web` (CI does not run `ui-new` checks): - `bun run test:format`: passes (was 39 files flagged). - `bun run typecheck`, `bun run test` (188 tests), and `bun run build`: pass. This pull request and its description were written by Isaac. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
Signed-off-by: Scott Haines <[email protected]>
Temporarily use rustls 0.23.44, the latest release available from the Databricks proxy. RUSTSEC-2026-0285 remains until the proxy mirrors rustls 0.23.45. Signed-off-by: Scott Haines <[email protected]>
Tables and metric views share UC's /tables/{full_name} resource, and UC's delete takes only the name. DeleteTable and DeleteView now read the resource first and return FAILED_PRECONDITION, deleting nothing, when it is the other kind; GetTable and GetView name the actual kind in their NOT_FOUND. The delete control stays available on both pages and names its type in the button, dialog, and success toast.
Signed-off-by: Scott Haines <[email protected]>
Co-authored-by: Isaac <[email protected]>
max_len counts characters, so a multibyte definition under 1 Mi characters could exceed the stated 1 MiB. Use max_bytes for function and metric-view definitions, which both validators support, and test the boundary through the bridge. Reserve the numbers and names of the fields this branch removed, as CallRequest already does, so a later field cannot reuse them while older SPA bundles are still served. Drop the orphaned FunctionLanguage comment. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
The proxy repeated the typed services' request handling, and the copies had drifted: typed calls dropped non-UTF-8 header values, and the proxy mapped body-read failures to internal. Upstream::send now owns header forwarding, the deadline, and the size-limited read for both. An oversized reply is internal rather than resource_exhausted, which Connect sends as HTTP 429; the proxy keeps its lower 4 MiB limit. Add proxy tests for an invalid method, an unreachable server, a stalled body, and an oversized reply. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
Invalid booleans already stopped the bridge, but a bad PORT silently fell back to 8081. Reject a PORT outside 1-65535 the same way, and log the error and exit instead of panicking through expect. Document the accepted boolean values and the startup failure in the README. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
The bridge no longer serves the SPA, and Nginx arrives only with the container setup, so describe Vite in development and a separate web server in production, as the README does. Pin 404 for unknown RPCs and non-RPC paths, and internal for malformed UC list replies. Format a Layout test assertion Prettier flagged so bun run test:format passes. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
545f29e to
3816e02
Compare
TableKind treated every table_type other than METRIC_VIEW as a table, including a missing or unknown one, so DeleteTable could send a DELETE without knowing what it was deleting. Classify through the existing mapping::table_type: METRIC_VIEW is a metric view, the other known types (MANAGED, EXTERNAL, VIEW, MATERIALIZED_VIEW, STREAMING_TABLE) are tables, and anything else is an internal error in list, get, and delete alike. Cover missing and unknown kinds, known non-metric types, and a failed lookup, none of which may reach the DELETE. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
ui-new has not shipped: its only clients are the SPA and bridge built from the same tree, so no deployed binary depends on the numbers or names of removed fields. Remove the reservations, including CallRequest's, so later contract changes can reuse those fields freely. The JSON decoder still drops unknown serverUrl and token keys, and the proxy test that guards against a client-chosen upstream or body token keeps passing under a name that no longer describes them as removed fields. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
reqwest's per-request timeout replaces the client timeout instead of capping it, so a Connect-Timeout-Ms above 30 seconds lifted the bridge's limit on UC requests. Typed RPCs already did this on main, and this branch extends it to the proxy. Apply connectrpc's DeadlinePolicy with the limit as both maximum and default: a longer client deadline is clamped, a missing one gets the limit, and the whole handler, including a delete's lookup and DELETE, shares one budget. The limit is UPSTREAM_TIMEOUT, carried on AppState next to the client it configures so tests can shorten it. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
The earlier pin held rustls at 0.23.44 until the registry mirror carried 0.23.45, which fixes RUSTSEC-2026-0285. The mirror has it now, so move to it; the checksum matches the crates.io release. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
Nothing outside the crate uses proxy, so make it private, and mark UiRpc's upstream pub(crate), which is what pub(super) meant. Read ALLOWED_ORIGINS through env_value so a non-Unicode value fails startup like every other variable. Note on the definition fields that their 1 MiB UTF-8 limit sits below UC's 16,777,215 characters, and on the table and metric-view deletes that the kind check is best effort. In the README, restore the index.html fallback the web server needs for client-side routes and say an empty boolean or PORT is invalid; in AGENTS.md, describe the test harness's rpc handlers for typed services and UcHandler for the proxy. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
Pin the proxy's query forwarding, its dropping of empty-key pairs, and the default JSON content type. Drive the mapping rejections from one table: a missing or empty identity, a nameless column or parameter, a version without a model name, and a zero, negative, or non-numeric version; and read the model name from either key. Extend the malformed-reply test to a single-object Get, reject empty booleans, and check the delete controls and toast for multi-word types. Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
|
Addressed the second AI review. First, the branch is rebased onto
Also smoke-tested against a disposable |
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Summary: no blockers, but I would not call this approve-worthy yet.
- Config (inline): the non-Unicode fallback and the empty-value startup failure need a decision, and
from_envneeds a test. - Table and view lists (inline): one unclassified
table_typefails the whole page. Forward-compatibility follow-up. - Docs (inline): stale wording in
ui-new/AGENTS.mdandbuild_cors.
Question on scope: this PR is a consolidation refactor (UiRpc, Upstream::send, borrowed views) that also changes behavior: kind-checked table and view get and delete, the deadline clamp, startup config strictness, SPA hosting removed, the 1 MiB definition limit, removed proto fields, and the delete labels. Would it make sense to land the refactor first as its own PR, with the behavior changes after it? ui-new is unshipped, so the cost is low, but a zero-behavior-change refactor is easier to review.
Nit: the Summary says table_type is validated when mapping UC responses. It is checked on list, get, and delete only; create still maps a missing value to Unspecified. The Compatibility section is accurate, so the Summary could match it.
| port, | ||
| Ok(Config { | ||
| port: env_port("PORT", 8081)?, | ||
| uc_server: env_string("UC_SERVER", "http://localhost:8080"), |
There was a problem hiding this comment.
[AI Assisted] env_string still uses std::env::var(key).ok(), so a non-Unicode UC_SERVER (or GOOGLE_CLIENT_ID) silently falls back to the default. The Summary says invalid configuration is rejected at startup instead of silently falling back. Could env_string go through env_value and return the error, or could the Summary be narrowed to match?
| Config { | ||
| port, | ||
| Ok(Config { | ||
| port: env_port("PORT", 8081)?, |
There was a problem hiding this comment.
[AI Assisted] An empty PORT, UI_AUTH_ENABLED, OKTA_AUTH_ENABLED, or KEYCLOAK_AUTH_ENABLED now stops the bridge, where the previous code used the default. UC_SERVER, GOOGLE_CLIENT_ID, and ALLOWED_ORIGINS already treat empty as unset in this file. Deployment templates often render unset values as empty strings, so this would fail at startup for setups that worked before. Could empty be treated as unset in env_value, keeping the errors for non-empty invalid values? That also changes the rejects_unknown_and_empty_boolean_values case.
There was a problem hiding this comment.
Fixed in #2309 (e191eff). env_value now treats an empty value as unset for every variable, so an empty PORT or *_AUTH_ENABLED takes its default. A non-empty invalid value, including whitespace only, is still an error. The "" cases moved out of the parse tests, which are now rejects_unknown_boolean_values and parses_ports_from_1_to_65535, into the new from_lookup tests.
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { |
There was a problem hiding this comment.
[AI Assisted] Only parse_bool and parse_port are tested, so the from_env mapping (variable to default to error) is not. A lookup-closure variant, such as from_lookup(|key| ...), would let a test cover unset, empty, non-Unicode, and invalid values without mutating the process environment. That would have caught the two findings above.
There was a problem hiding this comment.
Done in #2309 (e191eff). from_env wraps a private from_lookup that takes the lookup as a closure with std::env::var's signature. Four table-driven tests cover unset and empty (defaults), all variables set, invalid values, and VarError::NotUnicode for each variable. They fail on the two findings above.
|
|
||
| /// Keeps the rows of one kind from a UC table list; a row of unknown kind | ||
| /// fails the whole list. | ||
| fn rows_of_kind(rows: &[Value], kind: TableKind) -> Result<Vec<&Value>, ConnectError> { |
There was a problem hiding this comment.
[AI Assisted] rows_of_kind fails the whole page when one row has an unknown table_type. The previous code kept such rows. The current spec enum is fully mapped, so no current server response hits this. Could list skip and log unclassified rows instead, so one new type on a future server does not make a schema's table list unusable? Get and delete can stay strict.
There was a problem hiding this comment.
Done in #2309 (ce42225). List now skips a row with a missing or unknown table_type and logs a warning with its name and type; TableKind::of returns an Option. Get and delete stay strict through kind_mismatch, which still returns internal and deletes nothing. One test sends a page with a managed table, a metric view, an unknown type, and a missing type through both ListTables and ListViews.
| `bun run generate` in `web/`, and update the Rust `CallRequest`/`CallResponse` | ||
| in `server/src/proxy.rs` to match (fields use proto3 JSON camelCase). | ||
| `bun run generate` in `web/`, and update the generated-service implementation | ||
| in `server/src/proxy.rs` (fields use proto3 JSON camelCase). |
There was a problem hiding this comment.
[AI Assisted] This note describes the removed serde structs, but server/src/proxy.rs is now a Connect service. Also, the build_cors doc in ui-new/server/src/lib.rs (around line 97) says "Same-origin (prod)", which reads as if the bridge still serves the SPA. "The SPA and the bridge share one origin" would be accurate.
|
@yili-db I will address your final round of feedback in a new PR. This one was merged after Robert gave the green light. |
|
@yili-db The follow-ups are in #2309, and each of your threads has a reply. All five are fixed in #2309.
|
**PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. (No separate issue; follow-up to the review on #2262.) - [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. (No feature change; the `ui-new` docs touched are updated here.) ## Summary Follow-up to #2262. This addresses the review @yili-db left after #2262 was approved and before it merged. Each topic is its own commit. ### Changes - **Bridge configuration** (`ui-new/server/src/config.rs`): - An empty variable is now treated as unset and takes its default. In #2262, an empty `PORT` or `*_AUTH_ENABLED` stopped the bridge, while the string variables already treated empty as unset. Deployment templates often render an unset value as an empty string, so setups that worked before #2262 failed at startup. A non-empty invalid value is still an error. - `UC_SERVER` and `GOOGLE_CLIENT_ID` now fail on a value that is not valid Unicode, like the other variables, instead of silently using the default. - `UC_SERVER` is trimmed and parsed at startup. A whitespace-only value, or one that is not an `http` or `https` base URL without a query or fragment (such as `uc.example.com:8080` or `http://uc:8080/?x=1`), now stops the bridge instead of starting it and failing every UC call with `unavailable`. An exactly empty `UC_SERVER` still takes the default. - `GOOGLE_CLIENT_ID` is trimmed. A blank value (empty or whitespace only) is unset and leaves the Google button off. Any other value must end in `.apps.googleusercontent.com`, or the bridge stops at startup. An ID with that suffix but not in the usual `<number>-<id>` shape (the shape of the example in [Google's client ID guide](https://developers.google.com/identity/oauth2/web/guides/get-google-api-clientid)) starts the bridge with a warning, because Google documents no grammar to enforce. Before, a whitespace-only or malformed ID turned the button on, and it failed on click. - `from_env` wraps a new private `from_lookup`, which takes the variable lookup as a closure. The tests cover unset, empty, invalid, and non-Unicode values for every variable without changing the process environment. - **Table and metric-view lists** (`ui-new/server/src/services/`): a row with a missing or unknown `table_type` is skipped instead of failing the whole `ListTables` or `ListViews` page, and one warning per page names the catalog and schema and gives the count and up to three examples. A page where every row is skipped returns an empty list with the page token passed through. The current UC enum is fully mapped, so no current server sends such a row, but one table type added by a newer server would otherwise make a schema's lists unusable. `GetTable`, `GetView`, `DeleteTable`, and `DeleteView` stay strict: a resource of no known kind is still `internal`, and nothing is deleted. - **Docs:** - `ui-new/README.md` describes the new empty-value and non-Unicode startup behavior. - The bridge-contract note in `ui-new/AGENTS.md` no longer describes the removed `CallRequest`/`CallResponse` serde structs. Its camelCase hint now says that Connect's JSON encoding uses proto3 JSON camelCase field names. - The `build_cors` doc no longer reads as if the bridge serves the SPA. - `env_value` and `kind_mismatch` document their contracts. ## Compatibility and behavior changes The Java REST API and the OpenAPI specs are unchanged. ui-new has not shipped. Compared with `main`, the bridge behaves differently in five cases: - An empty `PORT`, `UI_AUTH_ENABLED`, `OKTA_AUTH_ENABLED`, or `KEYCLOAK_AUTH_ENABLED` now starts the bridge with the default instead of stopping it. - A non-Unicode `UC_SERVER` or `GOOGLE_CLIENT_ID` now stops the bridge with an error naming the variable. The non-Unicode error message is now `"<VAR> is not valid Unicode"`, without the raw value. - A whitespace-only `UC_SERVER` now stops the bridge with `UC_SERVER must not be whitespace only`, and one that is not an `http` or `https` base URL without a query or fragment stops it with `UC_SERVER must be an http or https base URL without a query or fragment, such as http://localhost:8080`. - A whitespace-only `GOOGLE_CLIENT_ID` now leaves the Google button off, a non-blank one that does not end in `.apps.googleusercontent.com` stops the bridge with an error naming the variable, and one in an unusual shape logs a warning. - A list page with an unclassified row now returns the other rows instead of `internal`. ## Validation - `cargo test --locked` passed (56 tests); `cargo fmt --check` and `cargo clippy --all-targets` are clean. - The new list test fails against `main`'s `services/` code and passes with this change. - No `web/` or proto files change. ## Stack This PR is independent of the remaining ui-new branches. `chore/add-ui-web-validation-tests` adds a `UI_RPC_VALIDATION_ENABLED` setting in `from_env`; when it is rebased onto this change, that line moves into `from_lookup`. This pull request and its description were written by Isaac. --------- Signed-off-by: Scott Haines <[email protected]> Co-authored-by: Isaac <[email protected]>
PR Checklist
docsis updated. (ui-new is documented inui-new/README.md, updated here.)Summary
Follow-up to #2190. This consolidates the ui-new RPC implementation, reduces duplicated request handling, and rejects malformed upstream responses instead of constructing incomplete objects. The Prettier reformatting it used to carry landed separately in #2292.
Changes
UiRpcimplementation across the typed services and register the control-plane proxy through the generated Connect service.Upstream::send) between the typed services and the proxy: header forwarding, the caller's deadline, and the size-limited read.table_typewhen mapping UC responses./tables/{full_name}resource, so each typed get and delete reads the kind first.Set-Cookieheaders.Compatibility and behavior changes
The Java REST API and OpenAPI specifications are unchanged. ui-new has not shipped, so the SPA/bridge contract changes below need no migration, but they do change behavior:
serverUrlortokenkeys are now ignored;mainrejected them with 400. The bridge always uses its configuredUC_SERVER, and a bearer token travels only in the Authorization header.WEB_DISTis gone. Vite or a separate web server must serve the SPA, proxy bridge requests, and fall back toindex.htmlfor client-side routes.max_bytes). That narrowsmain's 16,777,215-character limit, which matches UC's columns, and removes the 128 MiB request-limit overrides on those two routes. Requests use Connect's default 4 MiB limit, so a definition that JSON escaping expands past 4 MiB is rejected by the transport rather than the rule; for example, control characters escape to 6 bytes each. Either way it fails closed.DeleteTableandDeleteViewread the resource before deleting it. The wrong kind returnsFAILED_PRECONDITIONand deletes nothing.GetTableandGetViewname the actual kind in theirNOT_FOUND.table_typeisINTERNALin list, get, and delete, and nothing is deleted.Connect-Timeout-Msis clamped to the bridge's 30-second upstream limit, which also applies when the client sends none. Typed RPCs onmainhonored any client value.internalinstead ofresource_exhausted(HTTP 429). Proxy body-read failures map tounavailableordeadline_exceeded, as the typed services' do.PORTor*_ENABLEDvalue, or a non-UnicodeALLOWED_ORIGINS, stops the bridge with an error naming the variable.Validation
Checked on this branch:
bun run proto:check,bun run typecheck,bun run test:format, andbun run buildpassed.cargo test --lockedpassed (50 tests);cargo fmt --checkpassed.unitycatalog:v0.8.0-SNAPSHOTserver through this branch's bridge: created a catalog, schema, external table, and metric view; confirmed wrong-kind gets and deletes were refused and both objects survived; deleted each through its own service; and listed catalogs with a 10-minuteConnect-Timeout-Ms. All 19 checks passed.unauthenticated, as expected.Dependencies
Updates rustls from 0.23.43 to 0.23.45, which fixes RUSTSEC-2026-0285.
Stack
This PR targets
mainafter #2190 and #2292. Follow-up branches, each depending on the previous one:feat/add-ui-docker-environmentschore/add-ui-web-validation-testschore/add-jwt-copy-btnThis pull request and its description were written by Isaac.