feat(nodejs): expose Function failure recovery APIs (#5209)

TypeScript callers can now inspect and recover Function row failures
through the native workflow. `functionErrors()` groups returned failures
and can show retained attempt history. `functionErrorRows()` looks up
current failed inputs using row IDs and physical row addresses
represented as `bigint`. Older deployments can continue to use the
existing error listing.

`retryFailed()` selects the exact failed rows on the server, with
optional error type and job filters. `upgradeColumn()` binds an existing
immutable Function version and can recompute failed rows, all eligible
rows, or no rows. Callers can quarantine and release failures,
explicitly include quarantined rows in a retry, and use
`functionProvenance()` to see which Function version produced a recorded
value.

The native operations reuse the existing Rust workflow v1 capability
checks. The Function failures guide includes TypeScript examples for
inspecting, retrying, upgrading, and quarantining failures.
This commit is contained in:
Xuanwo
2026-11-25 23:14:04 +08:00
committed by GitHub
parent 757dcc0a6b
commit 4d9fd358f8
24 changed files with 2257 additions and 64 deletions
+70 -15
View File
@@ -16,10 +16,11 @@ The recipes that follow it remain available for older deployments.
## Native workflow: server contract version 1 {#native}
This section requires Python SDK 0.42.0b19 or later and an Enterprise
This section uses the native recovery APIs in Python SDK 0.42.0b19 or later and
in Rust and TypeScript SDKs that expose them. It requires an Enterprise
deployment advertising `workflow_version >= 1` in its Function error response.
The SDK checks this capability before submitting native retry, upgrade,
quarantine, history or provenance requests, and rejects unsupported servers
quarantine, history or provenance requests and rejects unsupported servers
before changing the column.
New Function refreshes default to `error_policy="skip"` with a 5% failed-row
@@ -30,7 +31,9 @@ failures remain job failures. External effects can repeat during recovery.
Read current unresolved failures, group their causes and inspect their inputs:
```python
<CodeGroup>
```python Python
errors = table.function_errors(column="embedding")
print(errors.summary())
inputs = errors.rows(columns=["text"])
@@ -40,23 +43,54 @@ history = table.function_errors(column="embedding", history=True)
print(history.records) # Retained attempts, including repaired failures.
```
```typescript TypeScript
const errors = await table.functionErrors({ column: "embedding" });
if (!errors.truncated && errors.fragments.length === 0) {
console.log(errors.errorGroups);
}
const inputs = await table.functionErrorRows({ column: "embedding", columns: ["text"] });
for (const { input, error } of inputs) {
console.log(input.text, error.rowId, error.errorType);
}
const history = await table.functionErrors({ column: "embedding", history: true });
console.log(history.records);
```
</CodeGroup>
The default listing deduplicates failures by row and Function column, retaining
attempt counts and first/last failure times. `summary()` and `rows()` refuse
incomplete selections; narrow a truncated request before inspecting it.
Historical records cannot be joined to current inputs through `rows()`.
Stable row IDs survive compaction; older physical-only records are rejected
for exact retry if their fragments have been rewritten.
attempt counts and first/last failure times. In Python, `summary()` and `rows()`
require a complete listing. In TypeScript, `errorGroups` counts the returned
records and `functionErrorRows()` requires a complete current listing. Narrow a
truncated request before using its counts as totals. Read historical attempts
through the returned records.
Stable row IDs survive compaction. TypeScript exposes row IDs and physical
addresses as `bigint`. Older physical-only records are rejected for exact
retry if their fragments have been rewritten.
Select retry rows on the server, optionally by exception class or job:
```python
<CodeGroup>
```python Python
retry_job = table.retry_failed("embedding", error_type="ValueError")
retry_job.wait()
```
```typescript TypeScript
const retryJob = await table.retryFailed("embedding", { errorType: "ValueError" });
const { rowsAssigned, rowsFailed } = await retryJob.wait();
console.log(rowsAssigned, rowsFailed);
```
</CodeGroup>
Upgrade the existing Function binding and choose which values to recompute:
```python
<CodeGroup>
```python Python
upgrade_job = table.upgrade_column("embedding", version="2", recompute="failed")
upgrade_job.wait()
provenance = table.function_provenance("embedding")
@@ -64,6 +98,17 @@ if not provenance.truncated:
print(provenance.records)
```
```typescript TypeScript
const upgradeJob = await table.upgradeColumn("embedding", { version: "2", recompute: "failed" });
await upgradeJob.wait();
const provenance = await table.functionProvenance("embedding");
if (!provenance.truncated) {
console.log(provenance.records);
}
```
</CodeGroup>
The immutable target version must already exist for the same Function.
`recompute="failed"` selects current failures; `"all"` recomputes all live rows;
`"none"` changes the binding while preserving existing values. The default is
@@ -74,18 +119,28 @@ recorded provenance do not acquire an invented producing version.
Quarantine failures that need input repair, then explicitly include them when
they are ready to retry:
```python
<CodeGroup>
```python Python
table.quarantine_failed("embedding", after_attempts=3)
retry_job = table.retry_failed("embedding", include_quarantined=True)
retry_job.wait()
```
```typescript TypeScript
await table.quarantineFailed("embedding", { afterAttempts: 3 });
const retryJob = await table.retryFailed("embedding", { includeQuarantined: true });
await retryJob.wait();
```
</CodeGroup>
Ordinary and automatic refreshes exclude quarantined rows, including during
an `"all"` upgrade. Explicit inclusion releases quarantine before the retry.
Async tables expose the same operations with `await`; `function_errors()`
returns `AsyncFunctionErrors`, and its `rows()` method is also awaited.
These native recovery APIs are available in Python and Rust. TypeScript does
not yet expose them; its SDK support is tracked as a separate follow-up.
To release rows for a later refresh, set `quarantined=False` in Python or
`quarantined: false` in TypeScript when calling the quarantine method.
Async Python tables expose the same operations with `await`, including
`rows()` on the `AsyncFunctionErrors` listing.
The equivalent Rust operations use explicit request options: