fix: preserve terminal server identity in failed job waits (#5024)

A failed remote Function job loses its persisted build identity when
converted into the exception from `job.wait()`. Append
`result.terminal_server` to that error using the existing server-build
format, preserving its message, row location, traceback and job ID. Do
not substitute the responding query node's version for the writer of the
saved terminal result; missing or malformed historical identity leaves
the error unchanged.

The reported failure was independently reproduced against a deployed
server with a real Function job. The new exact Rust regression
reproduces the missing terminal identity on the unpatched code. At
`59c1f3e`, all 10 remote Job Rust tests and five tests using the
matching native Python extension passed, including sync/async waits with
known or unknown terminal identity. These transport tests use mocked
HTTP responses; the original deployed Function job remains with
independent acceptance for recheck after delivery. This change does not
establish whole-ticket acceptance.
This commit is contained in:
Xuanwo
2026-11-14 20:59:10 +08:00
committed by GitHub
parent 0d55457d9e
commit 005b33fa8b
2 changed files with 155 additions and 6 deletions
+63
View File
@@ -2991,6 +2991,69 @@ def test_remote_job_wait_raises_on_failure():
assert exc_info.value.sql_job_id is None
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False])
@pytest.mark.parametrize("with_terminal_server", [True, False])
async def test_remote_job_wait_preserves_terminal_build(sync, with_terminal_server):
from lancedb.exceptions import JobFailedError
message = "ValueError: corrupt frame at frame_index=207"
server = {
"release": "1.13.0-beta.0",
"git_sha": "2a7874ecd589",
"build_date": "2026-11-12T22:45:43Z",
}
result = {"terminal_server": server} if with_terminal_server else None
def handler(request):
assert request.path == "/v1/jobs/describe"
request.send_response(200)
request.send_header("Content-Type", "application/json")
request.send_header(
"x-lancedb-server-build",
json.dumps({"release": "2.0.0", "git_sha": "new-query-node"}),
)
request.end_headers()
request.wfile.write(
json.dumps(
{
"job_id": "job-provenance",
"job_state": "FAILED",
"failure": {
"phase": "function_refresh_attempt_failed",
"message": message,
"traceback": "Traceback: original user code",
"retryable": False,
},
"result": result,
}
).encode()
)
if sync:
with mock_lancedb_connection(handler) as db:
job = db.open_job("job-provenance")
with pytest.raises(JobFailedError) as caught:
job.wait()
else:
async with mock_lancedb_connection_async(handler) as db:
job = await db.open_job("job-provenance")
with pytest.raises(JobFailedError) as caught:
await job.wait()
expected = f"Job job-provenance failed: {message}"
if with_terminal_server:
expected += (
" [server: 1.13.0-beta.0 (git 2a7874ecd589, built 2026-11-12T22:45:43Z)]"
)
expected += " (in function_refresh_attempt_failed)"
assert str(caught.value) == expected
assert caught.value.job_id == "job-provenance"
assert job.failure.message == message
assert job.failure.traceback == "Traceback: original user code"
assert job.result == result
@pytest.mark.parametrize("server_version", ["0.2.0", "0.6.0"])
def test_remote_json_fts_config(server_version):
from lancedb.index import FTS