Skip to content

[UI] Consolidate RPC handlers and tighten bridge response validation - #2262

Merged
newfront merged 13 commits into
unitycatalog:mainfrom
newfront:feat/add-rpc-implementations
Nov 19, 2026
Merged

newfront merged 13 commits into
unitycatalog:mainfrom
newfront:feat/add-rpc-implementations

Conversation

@newfront

@newfront newfront commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

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. (No separate issue; follow-up to [UI] ui-new: migrate the web UI to typed RPC services and implement the UI components #2190.)
  • 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. (ui-new is documented in ui-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

  • Share one UiRpc implementation across the typed services and register the control-plane proxy through the generated Connect service.
  • Share one upstream round trip (Upstream::send) between the typed services and the proxy: header forwarding, the caller's deadline, and the size-limited read.
  • Cap client-asserted deadlines at the bridge's 30-second upstream limit.
  • Use borrowed protobuf request views instead of cloning entire requests.
  • Validate required object identities, positive model-version numbers, and table_type when mapping UC responses.
  • Bound the table and metric-view RPCs to their own kind. Both share UC's /tables/{full_name} resource, so each typed get and delete reads the kind first.
  • Preserve auth/CSRF header forwarding and propagate multiple Set-Cookie headers.
  • Reject invalid configuration values at startup instead of silently falling back.
  • Simplify the web test harness around typed service implementations and share query-parameter conversion.

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:

  • Protobuf contract: unused response fields and enums are removed outright, without reservations. A Call body's serverUrl or token keys are now ignored; main rejected them with 400. The bridge always uses its configured UC_SERVER, and a bearer token travels only in the Authorization header.
  • SPA hosting: the bridge no longer serves the SPA, and WEB_DIST is gone. Vite or a separate web server must serve the SPA, proxy bridge requests, and fall back to index.html for client-side routes.
  • Definition limits: function and metric-view definitions are limited to 1 MiB of UTF-8 (max_bytes). That narrows main'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.
  • Table and metric-view kinds:
    • DeleteTable and DeleteView read the resource before deleting it. The wrong kind returns FAILED_PRECONDITION and deletes nothing.
    • GetTable and GetView name the actual kind in their NOT_FOUND.
    • A reply with no known table_type is INTERNAL in list, get, and delete, and nothing is deleted.
    • UC's delete takes only the name, so the check is best effort against a concurrent drop-and-recreate.
  • Delete controls: on every detail page, the button, dialog title, and success toast name their type (for example, "Delete metric view").
  • Deadlines: a client's Connect-Timeout-Ms is clamped to the bridge's 30-second upstream limit, which also applies when the client sends none. Typed RPCs on main honored any client value.
  • Error codes: an oversized UC response is internal instead of resource_exhausted (HTTP 429). Proxy body-read failures map to unavailable or deadline_exceeded, as the typed services' do.
  • Configuration: an invalid or empty PORT or *_ENABLED value, or a non-Unicode ALLOWED_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, and bun run build passed.
  • Web coverage passed: 193 tests, 95.4% line coverage.
  • Rust: cargo test --locked passed (50 tests); cargo fmt --check passed.
  • Against a disposable unitycatalog:v0.8.0-SNAPSHOT server 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-minute Connect-Timeout-Ms. All 19 checks passed.
  • Signed-out reads against a remote, auth-enabled UC over HTTPS returned unauthenticated, as expected.

Dependencies

Updates rustls from 0.23.43 to 0.23.45, which fixes RUSTSEC-2026-0285.

Stack

This PR targets main after #2190 and #2292. Follow-up branches, each depending on the previous one:

  1. feat/add-ui-docker-environments
  2. chore/add-ui-web-validation-tests
  3. chore/add-jwt-copy-btn

This pull request and its description were written by Isaac.

@newfront

Copy link
Copy Markdown
Collaborator Author

/review

@newfront newfront changed the title Feat/add rpc implementations [UI] Consolidate RPC handlers and tighten bridge response validation Nov 18, 2026
@newfront newfront added this to the 0.8 milestone Nov 18, 2026
@newfront newfront added the enhancement New feature or request label Nov 18, 2026
@newfront

Copy link
Copy Markdown
Collaborator Author

Addressed the AI review in five commits:

  • Blocker, wrong-kind delete: ce61079. DeleteTable and DeleteView read the resource first and return failed_precondition, deleting nothing, for the other kind. GetTable and GetView name the actual kind in their not_found. The Delete control stays available and names its type in the button, dialog, and toast. Bridge tests cover matching and mismatched kinds for gets and deletes, with no DELETE sent on a mismatch; page tests cover the refused delete on both pages. UC's delete takes only the name, so a drop-and-recreate between the read and the delete would need a UC API change to rule out.
  • Nit 1, characters vs. bytes: 15ac4cc. Both definitions use max_bytes: 1048576, which the pinned Rust codegen and protovalidate-es support. Boundary tests through app(...) cover the limit, one byte over, multibyte text under 1 Mi characters but over 1 MiB, and a quote-heavy definition.
  • Nit 2, stale comments: 545f29e, plus the FunctionLanguage comment in 15ac4cc.
  • Nit 3, unreserved fields: 15ac4cc reserves the 24 removed fields across six messages.
  • Nit 4, duplicated round trip: 8645158. Upstream::send now owns header forwarding, the deadline, and the size-limited read for both paths. An oversized reply is internal; the proxy keeps its 4 MiB limit.
  • Nit 5, configuration: e0e778c. PORT is parsed strictly, startup errors exit cleanly, and the README lists the accepted boolean values.
  • Nit 6, test gaps: proxy invalid-method, unreachable, stalled-body, and oversized cases in 8645158; unknown routes and malformed lists in 545f29e. The "no preliminary GET" assertion is superseded by the blocker's type check.

@newfront

Copy link
Copy Markdown
Collaborator Author

/review

@newfront
newfront marked this pull request as ready for review November 18, 2026 01:48
@newfront newfront mentioned this pull request Nov 18, 2026
1 of 4 tasks
newfront added a commit that referenced this pull request Nov 19, 2026
**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]>
newfront and others added 7 commits November 18, 2026 16:38
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]>
@newfront
newfront force-pushed the feat/add-rpc-implementations branch from 545f29e to 3816e02 Compare November 19, 2026 00:40
newfront and others added 6 commits November 18, 2026 16:44
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]>
@newfront

Copy link
Copy Markdown
Collaborator Author

Addressed the second AI review. First, the branch is rebased onto main after #2292, which took the Prettier-only changes out of this diff (77 → 39 files).

  • Blocker 1, unclassified table_type: 33ab881. Classification reuses mapping::table_type. METRIC_VIEW is a metric view; the other known types are tables. That includes VIEW, MATERIALIZED_VIEW, and STREAMING_TABLE, so the suggested MANAGED | EXTERNAL match would have broken those rows. A missing or unknown value is internal in list, get, and delete, and nothing is deleted. Tests cover missing and unknown kinds, known non-metric types, and a lookup failing with 404, 403, or 500, with no DELETE sent in any refused case.
  • Blocker 2, deadline override: 650f6cd. This uses connectrpc's DeadlinePolicy with the bridge limit as both maximum and default, instead of a min() in Upstream::send, so the whole handler, including a delete's lookup and DELETE, shares one budget. The limit is defined once (UPSTREAM_TIMEOUT, carried on AppState). Tests cover no header, a header far above the limit, and a header below it.
  • Nit 1, visibility: f2af968.
  • Nit 2, ALLOWED_ORIGINS: f2af968.
  • Nit 3, byte-limit wording: the description now states the escaping bound and the narrowing from 16,777,215 characters; f2af968 adds the proto comments.
  • Nit 4, docs:
    • rustls line: e1233c6 now moves to 0.23.45, which fixes RUSTSEC-2026-0285, so the caveat is gone.
    • README index.html fallback and AGENTS.md test harness: f2af968.
    • proxy.proto "Removed:" comment: af4de8f drops all field reservations. ui-new hasn't shipped, so no deployed client depends on the removed numbers.
    • serverUrl/token and proxy statuses: now in the description.
  • Nit 5, test gaps: 47bbbcd covers proxy query forwarding, empty-key filtering, and the default content type; table-driven mapping rejections and the model_name/name fallback; a malformed single-object Get; empty booleans; and multi-word delete labels. 33ab881 covers the GET-before-delete failures. Config::from_env itself isn't tested, because that would change environment variables shared by tests running in parallel; the parse functions it uses are covered.
  • Nit 6, delete safety: f2af968 calls the check "best effort" in both delete comments. The empty-page note was already on both List*Response messages.

Also smoke-tested against a disposable unitycatalog:v0.8.0-SNAPSHOT server; details are in the description.

@newfront

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] 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_env needs a test.
  • Table and view lists (inline): one unclassified table_type fails the whole page. Forward-compatibility follow-up.
  • Docs (inline): stale wording in ui-new/AGENTS.md and build_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"),

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] 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?

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.

Fixed in #2309 (e191eff). env_string now goes through env_value and returns its error, so a non-Unicode UC_SERVER or GOOGLE_CLIENT_ID stops the bridge with <VAR> is not valid Unicode, like the other variables.

Config {
port,
Ok(Config {
port: env_port("PORT", 8081)?,

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] 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.

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.

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 {

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] 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.

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.

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> {

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] 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.

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.

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.

Comment thread ui-new/AGENTS.md
`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).

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] 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.

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.

Both fixed in #2309 (64b5f8c). The AGENTS.md note now says to update the UnityProxyService implementation in server/src/proxy.rs, and the build_cors doc says a reverse proxy or the Vite dev proxy puts the SPA and the bridge on one origin.

@newfront
newfront merged commit e8173f3 into unitycatalog:main Nov 19, 2026
19 checks passed
@newfront

newfront commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

@yili-db I will address your final round of feedback in a new PR. This one was merged after Robert gave the green light.

@newfront newfront mentioned this pull request Nov 19, 2026
3 of 4 tasks
@newfront

newfront commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

@yili-db The follow-ups are in #2309, and each of your threads has a reply. All five are fixed in #2309.

  • Scope: Agreed, it would have been easier to review as two PRs. This one merged before I split it, so I'll keep refactors and behavior changes in separate PRs for the rest of the ui-new stack.
  • Summary nit: You're right. Create still maps a missing table_type to Unspecified; only list, get, and delete check it, and the Compatibility section is the accurate description. After [UI] Address follow-up review on #2262 #2309, list skips an unclassified row instead of returning internal, and get and delete stay strict.

yili-db pushed a commit that referenced this pull request Nov 20, 2026
**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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants