Repository navigation
[UI] Address follow-up review on #2262 - #2309
Conversation
unitycatalog#2262 made the bridge fail at startup on invalid configuration, but two paths still disagreed with that: - An empty PORT or *_AUTH_ENABLED stopped the bridge, while the string variables treated empty as unset. Deployment templates often render an unset value as an empty string, so setups that worked before failed. Every variable now treats empty as unset; a non-empty invalid value is still an error. - UC_SERVER and GOOGLE_CLIENT_ID read through `std::env::var(..).ok()`, so a non-Unicode value silently fell back to the default. They now go through `env_value` and fail like the other variables. `from_env` now wraps `from_lookup`, which takes the variable lookup as a closure, so the tests cover unset, empty, invalid, and non-Unicode values without changing the process environment. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
`rows_of_kind` failed the whole ListTables or ListViews page when one row had a missing or unknown `table_type`. The current UC enum is fully mapped, so no current server hits this, but one table type added by a newer server would make a schema's table and metric-view lists unusable. List now skips such a row and logs a warning naming it. Get and delete stay strict: a resource of no known kind is still `internal`, so it is never read or deleted as a table. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
- ui-new/AGENTS.md: the bridge-contract note still described the removed `CallRequest`/`CallResponse` serde structs. `server/src/proxy.rs` is now the generated `UnityProxyService` implementation. - `build_cors`: "Same-origin (prod)" read as if the bridge still serves the SPA. Same-origin now comes from a reverse proxy or the Vite dev proxy in front of the bridge. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
/review |
`rows_of_kind` logged one warning per unclassified row on every list call, so a table type that a newer UC server uses widely would log a line per row on each page load. It now logs one warning per page with the count and up to three examples, each with its name and raw `table_type`. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
- ui-new/README.md still said an empty boolean or `PORT` stops the bridge. An unset or empty variable now takes its default; a non-empty invalid value, or one that is not valid Unicode, still stops it. - `env_value`: say that only an exactly empty value counts as unset; a whitespace-only value is validated like any other. - `kind_mismatch`: document its three outcomes. - ui-new/AGENTS.md: restore the camelCase hint dropped earlier in this PR, reworded for the generated Connect service: Connect's JSON encoding uses proto3 JSON camelCase field names, as in the bridge tests' request bodies. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
Addressed the AI review in two commits:
The description is updated to match. |
|
/review |
`rows_of_kind` pushed unclassified rows into a vector from inside a `filter` predicate. It is now a plain loop that matches each row's kind once. The warning also names the listed catalog and schema, which the row examples alone did not identify. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
The shared list test now skips `FOREIGN` and empty `table_type` rows as well as unknown and missing ones. It also sends a page where every row is skipped, and checks that both `ListTables` and `ListViews` return an empty list with the page token passed through. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
- `from_env`: say that an unset or empty variable takes its default, and that an invalid `PORT` or boolean, or a non-Unicode value, is an `Err` naming the variable. - `env_value`: "validated like any other" was wrong for the string variables. A whitespace-only value is kept; `PORT` and the booleans reject it, and `UC_SERVER` and `GOOGLE_CLIENT_ID` use it as given, as before this PR. - ui-new/AGENTS.md: name `server/tests/proxy.rs` as the example of camelCase request bodies. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
Addressed the second AI review in three commits:
The description is updated to match. |
A whitespace-only `UC_SERVER` was used as given, so the bridge started and failed only on its first call to Unity Catalog. It now stops the bridge at startup with "UC_SERVER must not be whitespace only". An unset or exactly empty `UC_SERVER` still takes the default, like every other variable, so deployment templates that render an unset value as "" keep working. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
Follow-up on nit 4 from the second AI review: 67cb4c2 now rejects a whitespace-only |
|
/review |
A whitespace-only `GOOGLE_CLIENT_ID` was used as given. `/config` returns it, and the SPA shows the Google button for any non-empty value, so the button appeared and failed on click with no startup warning. A malformed ID failed the same way. `GOOGLE_CLIENT_ID` is now trimmed. A blank value (empty or whitespace only) is unset and leaves the button off. Any other value must match Google's published format, `^[0-9]+-[a-z0-9]+\.apps\.googleusercontent\.com$`, or the bridge stops at startup with an error naming the variable. `env_string` has no callers left and is removed. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
`rows_of_kind` took the request's `SchemaRefView` only to label its warning. It now takes the catalog and schema names as `&str`, so it does not depend on the generated request type and its unit test can call it directly. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
Skipped rows no longer appear in the list response, so the warning is the only sign that a page is incomplete, and nothing asserted it. A unit test now runs `rows_of_kind` under a scoped `tracing` subscriber. It checks for exactly one warning per page with the catalog, schema, full count, and at most three examples, and for no warning when every row is recognized. Dropping the warning, logging it per row, or logging a fourth example each fails the test. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Summary: comment. One normal item inline (malformed UC_SERVER), plus nits. Non-Unicode, empty, and whitespace config cases were checked in a scratch run and behave as described.
Addressed from the #2262 review: items 1, 2, 3, 5 and 6 (config errors, empty values, from_lookup tests, skipping unclassified rows with a warning, and the AGENTS.md and build_cors wording).
Left as is: item 4 (splitting the refactor) and item 7 (the Summary wording on table_type validation). Both concern the merged #2262, so they are not raised again here.
| okta_enabled: env_bool("OKTA_AUTH_ENABLED", false)?, | ||
| keycloak_enabled: env_bool("KEYCLOAK_AUTH_ENABLED", false)?, | ||
| port: env_port(env, "PORT", 8081)?, | ||
| uc_server: env_non_blank(env, "UC_SERVER", "http://localhost:8080")?, |
There was a problem hiding this comment.
[AI Assisted] A non-blank but malformed UC_SERVER still starts the bridge, for example uc.example.com:8080 or not a url. The request builder fails on each UC call, so every RPC returns unavailable and the startup check does not catch it. The blank check exists for the same reason. Could UC_SERVER be parsed with reqwest::Url at startup, with an error that names the variable?
There was a problem hiding this comment.
Fixed in ffb34b9. UC_SERVER is now trimmed and parsed with reqwest::Url at startup. A value that does not parse, or whose scheme is not http or https, stops the bridge with UC_SERVER must be an http or https URL, such as http://localhost:8080. The scheme check is needed because a bare uc.example.com:8080 or localhost:8080 parses with the host as its scheme. uc_server_must_be_an_http_url covers those two, a bare host, not a url, ftp://, and http://, plus a padded URL with a base path that is accepted and trimmed.
|
|
||
| fn env_port(key: &str, default: u16) -> Result<u16, String> { | ||
| env_value(key)?.map_or(Ok(default), |value| parse_port(key, &value)) | ||
| fn env_port(env: Lookup<'_>, key: &str, default: u16) -> Result<u16, String> { |
There was a problem hiding this comment.
[AI Assisted] nit: a whitespace-only PORT or boolean still stops the bridge, while an empty value takes the default. The README documents this. Could you confirm that is intended, or treat blank like empty for templated values?
There was a problem hiding this comment.
Intended. An exactly empty value is how templates usually render an unset variable, so it takes the default. A whitespace-only PORT or boolean is more likely a mistake than an unset value. For UI_AUTH_ENABLED, defaulting would also silently turn the SPA's login gate off, so the bridge stops at startup and names the variable instead. A whitespace-only UC_SERVER fails the same way. GOOGLE_CLIENT_ID is the one exception: there, blank means unset, because its default (no Google button) is the safe result. The README documents all of this.
| port: env_port(env, "PORT", 8081)?, | ||
| uc_server: env_non_blank(env, "UC_SERVER", "http://localhost:8080")?, | ||
| auth_enabled: env_bool(env, "UI_AUTH_ENABLED", false)?, | ||
| google_client_id: env_string(env, "GOOGLE_CLIENT_ID", "")?, |
There was a problem hiding this comment.
[AI Assisted] nit: a whitespace-only GOOGLE_CLIENT_ID is kept as given and returned by /config, so the Google button can appear with an unusable id. Trimming it, or rejecting it as blank like UC_SERVER, would avoid that.
There was a problem hiding this comment.
Fixed in fd9ad6e. GOOGLE_CLIENT_ID is now trimmed, and a blank value is unset, so the Google button stays off. Any other value must match Google's client ID format, ^[0-9]+-[a-z0-9]+\.apps\.googleusercontent\.com$, or the bridge stops at startup. google_client_id_must_match_googles_format covers blank, valid, padded, and malformed values.
| .take(3) | ||
| .map(|row| describe_row(row)) | ||
| .collect(); | ||
| tracing::warn!( |
There was a problem hiding this comment.
[AI Assisted] nit: no test asserts the per-page warning. A test with a scoped tracing subscriber could check one warning with the catalog, schema, count, and up to three examples, and none when every row is recognized.
There was a problem hiding this comment.
Added in b8a3da2. rows_of_kind_warns_once_per_page_about_unclassified_rows runs rows_of_kind under a scoped tracing subscriber. It checks for exactly one warning with the catalog, schema, full count, and at most three examples, and for none when every row is recognized. Dropping the warning, logging it per row, or logging a fourth example each fails it.
| }; | ||
| let unclassified = vec![ | ||
| row("future", Some("SOME_NEW_TYPE")), | ||
| row("foreign", Some("FOREIGN")), |
There was a problem hiding this comment.
[AI Assisted] nit: add a comment that FOREIGN is intentionally outside the OSS TableType enum, and include the case index in the assert messages.
There was a problem hiding this comment.
Done in 460932c. Both list tests now say that FOREIGN is a Databricks Unity Catalog type outside the OSS TableType enum, and the list test's assert messages include the case index.
| /// Keeps the rows of one kind from a UC table list. Rows of no known kind are | ||
| /// skipped rather than failing the page, so a table type added by a newer UC | ||
| /// server does not break the list; one warning per page counts them. | ||
| fn rows_of_kind<'a>( |
There was a problem hiding this comment.
[AI Assisted] nit: rows_of_kind takes the whole SchemaRefView only for the log line. Passing the catalog and schema names, or logging in the callers, would narrow it.
There was a problem hiding this comment.
Done in 5e38965. rows_of_kind now takes catalog: &str, schema: &str instead of the SchemaRefView.
- `table_and_view_lists_keep_only_their_own_kind` runs two cases per RPC, and its assert messages named only the RPC. They now include the case index. - Both list tests use `FOREIGN` as an unclassified type. A comment says it is a Databricks Unity Catalog type outside the OSS `TableType` enum, so it is unclassified on purpose. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
Addressed the third AI review in four commits:
The description is updated to match. |
A non-blank but malformed `UC_SERVER`, such as `uc.example.com:8080` or `not a url`, still started the bridge. Every request to UC then failed, so every RPC returned `unavailable` and nothing at startup said why. `UC_SERVER` is now trimmed and parsed with `reqwest::Url` at startup. A value that does not parse, or whose scheme is not `http` or `https`, stops the bridge with "UC_SERVER must be an http or https URL, such as http://localhost:8080". The scheme check is needed because a bare `host:port` parses with the host as its scheme. The whitespace-only check and an unset or empty value's default are unchanged. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Summary: comment. Item A is partly addressed, with the query and fragment gap inline. Items C to F are addressed. The pushback on B is accepted.
Also a nit outside this diff: the comment above regex = "1" in ui-new/server/Cargo.toml (lines 23 to 25) says regex is only for generated CEL validators. config.rs now uses it directly, so the comment should say so. Cargo.toml is not in this PR's diff, so I am noting it here rather than inline.
| } | ||
| // A bare `host:port` parses with `host` as its scheme, so check the scheme. | ||
| match reqwest::Url::parse(value) { | ||
| Ok(url) if matches!(url.scheme(), "http" | "https") => Ok(value.to_string()), |
There was a problem hiding this comment.
[AI Assisted] A UC_SERVER with a query or fragment still passes this check, and it misroutes every UC call. Checked with a scratch run: http://uc:8080/?x=1 moves the API path into the query string, and http://uc:8080#frag moves it into the fragment, so requests go to /. Could the check also reject url.query() and url.fragment(), with http://uc?x and http://uc#f added to uc_server_must_be_an_http_url? The error text and README could then say base URL without query or fragment.
| } | ||
|
|
||
| /// Google's published format for an OAuth client ID. | ||
| const GOOGLE_CLIENT_ID_FORMAT: &str = r"^[0-9]+-[a-z0-9]+\.apps\.googleusercontent\.com$"; |
There was a problem hiding this comment.
[AI Assisted] Where does this pattern come from? The comment calls it Google's published format, but nothing in the repo defines it. If Google issues a valid client ID outside this pattern, the bridge stops at startup. Would a check on the .apps.googleusercontent.com suffix be enough, or is there a source for the grammar we can link?
Nit: Regex::new runs on every call to env_google_client_id. A LazyLock would compile it once.
The bridge builds each UC URL by appending the request path to `UC_SERVER`. With `http://uc:8080/?x=1`, the path ended up inside the query string; with `http://uc:8080#frag`, it ended up in the fragment, which is never sent. The startup check only tested the scheme, so the bridge started and every UC call failed. `UC_SERVER` must now also have no query or fragment, including an empty one such as a trailing `?` or `#`. Base paths such as `/uc/` are still accepted. The error and README say it must be a base URL without a query or fragment. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
/review |
The `rows_of_kind` warning test carried its own writer and scoped subscriber. The next commit adds a warning to the config reader that needs the same capture, so the helper moves to a test-only `test_logs::capture` module. The `rows_of_kind` test is unchanged apart from calling it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
…r shapes A `GOOGLE_CLIENT_ID` that Google accepts but that did not match the full `^[0-9]+-[a-z0-9]+\.apps\.googleusercontent\.com$` pattern would have stopped the bridge, and fixing that would need a bridge release. Google documents only an example ID, not a grammar. A non-blank value must still end in `.apps.googleusercontent.com`, with something before it, 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, now starts the bridge and logs a warning. The pattern compiles once in a `LazyLock`. The code and README no longer call it "Google's published format". Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
The comment above `regex = "1"` said the dependency exists only for the generated CEL validators, which a codegen upgrade would make unnecessary. `config.rs` now uses it for the `GOOGLE_CLIENT_ID` shape check, so the comment says to keep it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Scott Haines <[email protected]>
|
Addressed the fourth AI review in four commits:
The description is updated to match. |
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Approve. The remaining items (the description test count, the unbackticked <VAR>, the ALLOWED_ORIGINS wording, and the pre-existing userinfo logging followup) are small and do not need another round.
PR Checklist
docsis updated. (No feature change; theui-newdocs 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
ui-new/server/src/config.rs):PORTor*_AUTH_ENABLEDstopped 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 [UI] Consolidate RPC handlers and tighten bridge response validation #2262 failed at startup. A non-empty invalid value is still an error.UC_SERVERandGOOGLE_CLIENT_IDnow fail on a value that is not valid Unicode, like the other variables, instead of silently using the default.UC_SERVERis trimmed and parsed at startup. A whitespace-only value, or one that is not anhttporhttpsbase URL without a query or fragment (such asuc.example.com:8080orhttp://uc:8080/?x=1), now stops the bridge instead of starting it and failing every UC call withunavailable. An exactly emptyUC_SERVERstill takes the default.GOOGLE_CLIENT_IDis 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) 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_envwraps a new privatefrom_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.ui-new/server/src/services/): a row with a missing or unknowntable_typeis skipped instead of failing the wholeListTablesorListViewspage, 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, andDeleteViewstay strict: a resource of no known kind is stillinternal, and nothing is deleted.ui-new/README.mddescribes the new empty-value and non-Unicode startup behavior.ui-new/AGENTS.mdno longer describes the removedCallRequest/CallResponseserde structs. Its camelCase hint now says that Connect's JSON encoding uses proto3 JSON camelCase field names.build_corsdoc no longer reads as if the bridge serves the SPA.env_valueandkind_mismatchdocument 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:PORT,UI_AUTH_ENABLED,OKTA_AUTH_ENABLED, orKEYCLOAK_AUTH_ENABLEDnow starts the bridge with the default instead of stopping it.UC_SERVERorGOOGLE_CLIENT_IDnow 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.UC_SERVERnow stops the bridge withUC_SERVER must not be whitespace only, and one that is not anhttporhttpsbase URL without a query or fragment stops it withUC_SERVER must be an http or https base URL without a query or fragment, such as http://localhost:8080.GOOGLE_CLIENT_IDnow leaves the Google button off, a non-blank one that does not end in.apps.googleusercontent.comstops the bridge with an error naming the variable, and one in an unusual shape logs a warning.internal.Validation
cargo test --lockedpassed (56 tests);cargo fmt --checkandcargo clippy --all-targetsare clean.main'sservices/code and passes with this change.web/or proto files change.Stack
This PR is independent of the remaining ui-new branches.
chore/add-ui-web-validation-testsadds aUI_RPC_VALIDATION_ENABLEDsetting infrom_env; when it is rebased onto this change, that line moves intofrom_lookup.This pull request and its description were written by Isaac.