Add gRPC-to-HTTP query fallback, fix test spicepod version, strengthen browser test assertions - #316
Open
lukekim wants to merge 6 commits into
Open
Add gRPC-to-HTTP query fallback, fix test spicepod version, strengthen browser test assertions#316lukekim wants to merge 6 commits into
lukekim wants to merge 6 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…eamed The Flight channel can initialize successfully but then fail mid-query (observed as empty grpc-js status errors in serverless environments, e.g. Vercel functions). Previously doQueryRequest only fell back to HTTP when channel initialization failed, so these errors surfaced to callers. Now sql() falls back to HTTP on a failed Flight query unless flightOnly is set or partial results were already streamed to the caller's callback (which would deliver duplicate data). sqlJson() in gRPC mode routes through sql() and inherits the same behavior.
Spice Cloud's /v1/sql parses every request body as raw SQL and rejects
the {sql, parameters} JSON envelope with a 400 ParserError. The OSS
runtime accepts both formats (envelope only when Content-Type is
application/json).
Queries without parameters are now sent as text/plain raw SQL — the
format every endpoint accepts, and the pre-parameterized-queries
behavior. Parameterized queries keep the JSON envelope against the OSS
runtime, and fail fast with a clear error against Spice Cloud over
HTTP, where parameter binding requires Arrow Flight.
5 tasks
v2 is the current Spicepod manifest version (and the runtime default); validated against the released spiced v2.1.2 binary, which CI installs.
There was a problem hiding this comment.
Pull request overview
This PR improves SDK robustness by falling back from Arrow Flight (gRPC) to HTTP when a query fails after the channel has initialized, and adjusts HTTP request formatting to match what Spice Cloud and the OSS runtime actually accept. It also updates CI/runtime fixtures and strengthens test assertions around request bodies/headers.
Changes:
- Add query-time gRPC → HTTP fallback in
sql()with safeguards (no fallback inflightOnlyor after partial streaming). - Send raw SQL (
text/plain) over HTTP when there are no parameters; keep JSON envelope for parameterized queries on OSS, and fail fast for parameterized HTTP on Spice Cloud. - Update spicepod version for CI and add/strengthen unit + browser tests (and wire the new unit test into CI).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/client-common.ts |
Adds query-time gRPC→HTTP fallback logic and conditional HTTP body/content-type selection (raw SQL vs JSON envelope). |
test/grpc-http-fallback.test.ts |
New unit tests covering fallback behavior and HTTP body formats (including Spice Cloud rejection for parameterized HTTP). |
test/browser/client.test.ts |
Tightens browser-side assertions for HTTP request formats and makes config logging test deterministic via SPICE_DEBUG. |
test/scripts/spicepod.yaml |
Updates spicepod schema version to v1 for compatibility with latest spiced. |
.github/workflows/test.yml |
Runs the new gRPC→HTTP fallback unit tests in the local runtime CI job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e wins over custom headers - The SPICE_DEBUG test now restores the env var in a finally block (and deletes it when originally unset, since assigning undefined stores the string "undefined"). - doHttpQueryRequest merges custom headers before the computed Content-Type/Accept, so a caller override can no longer desync the headers from the conditionally-chosen body format. Added a unit test locking in the precedence.
sgrebnov
approved these changes
Aug 1, 2026
ewgenius
approved these changes
Aug 1, 2026
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.
Summary
Four changes, from most to least significant:
1. SDK: fall back to HTTP when an Arrow Flight query fails mid-query
The Flight channel can initialize successfully but then fail on the query itself — observed as empty grpc-js status errors (
undefined undefined: undefined) from the SDK running inside Vercel serverless functions, which made all Cloud Tests fail with 500s from the test app. PreviouslydoQueryRequestonly fell back to HTTP when channel initialization failed.Now
sql()falls back to HTTP on a failed Flight query, unless:flightOnlyis set (no HTTP transport to fall back to), orsqlJson()in gRPC mode routes throughsql()and inherits the same behavior. Falling back logs a warning through the configurable logger.2. SDK: send raw SQL over HTTP unless parameters require the JSON envelope
Deploying fix 1 exposed a second bug: Spice Cloud's
/v1/sqlparses every request body as raw SQL and rejects the{sql, parameters}JSON envelope (introduced in #268) with400 ParserError. The OSS runtime accepts both formats (verified against the runtime source and a local spiced).text/plainraw SQL — the format every endpoint accepts, and the pre-Add Parameterized Queries #268 behavior.New unit tests in
test/grpc-http-fallback.test.tscover all paths (6 tests), wired into the Local Runtime CI job.3. CI: fix test spicepod version (
v1beta1→v1)CI installs the latest spiced release, which dropped support for
v1beta1spicepods — the runtime failed to start and all six Local Runtime jobs failed withECONNREFUSED. Validated against a local spiced before pushing.4. Tests: strengthen browser client assertions for HTTP request formats
sql()asserts thetext/plainraw-SQL body; a new test asserts the JSON envelope for parameterized queries.sqlJson()test assertsContent-Type: text/plainwith the raw SQL body and theapplication/vnd.spiceai.sql.v1+jsonAccept header.SPICE_DEBUG=true(restored after), making it deterministic regardless ofNODE_ENV.Testing
test/grpc-http-fallback.test.ts— 6 tests passnpm run test:browser— 62 tests passParserErroron{)