Skip to content

Commit 877d881

Browse files
rustyconoverclaude
andcommitted
Release 0.53.2: hosted mode requires a stable VGI_SIGNING_KEY
A Field Worker's machines stop and start, and a deployment can span several: a key minted per process made every restart (or another machine) reject the sessions DuckDB already held ("attach_opaque_data not recognized"). VGI_ORCHARD_HOSTED=1 now refuses to start unless VGI_SIGNING_KEY is configured (not minted by vgi-serve) and at least 32 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzrG3FzSh28NiZ8UnVtRbk
1 parent 5e7733c commit 877d881

6 files changed

Lines changed: 52 additions & 4 deletions

File tree

‎packages/vgi-fixtures/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# and the conformance suite import it by its normal `vgi._test_fixtures` path.
99
[project]
1010
name = "vgi-fixtures"
11-
version = "0.53.1"
11+
version = "0.53.2"
1212
description = "Example/test VGI worker modules and entry points (not for production use)"
1313
readme = "README.md"
1414
# Local copy of the repo-root LICENSE (kept in sync): the build can't reach

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "vgi-python"
3-
version = "0.53.1"
3+
version = "0.53.2"
44
description = "Vector Gateway Interface - Connect DuckDB to external programs via Apache Arrow"
55
readme = "README.md"
66
keywords = [

‎tests/test_orchard_hosted.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,22 @@ def test_empty(self, name: str) -> None:
411411
"""An empty required variable refuses, the same as unset."""
412412
assert name in _refused(_env(_JWKS, **{name: " "}))
413413

414+
def test_signing_key_unset(self) -> None:
415+
"""No VGI_SIGNING_KEY refuses: a minted key breaks sessions on every restart."""
416+
assert "VGI_SIGNING_KEY" in _refused(_env(_JWKS, VGI_SIGNING_KEY=None))
417+
418+
def test_signing_key_short(self) -> None:
419+
"""A VGI_SIGNING_KEY under 32 bytes refuses."""
420+
stderr = _refused(_env(_JWKS, VGI_SIGNING_KEY="short-key"))
421+
assert "VGI_SIGNING_KEY" in stderr
422+
assert "32 bytes" in stderr
423+
424+
def test_signing_key_minted_by_vgi_serve(self) -> None:
425+
"""A key vgi-serve minted for its children is not a configured one."""
426+
env = _env(_JWKS, VGI_SIGNING_KEY="minted-by-a-parent-vgi-serve-process-0001")
427+
env["VGI_SIGNING_KEY_MINTED"] = "1"
428+
assert "VGI_SIGNING_KEY" in _refused(env)
429+
414430
def test_comma_audience(self) -> None:
415431
"""The audience is one canonical Desk Address, never a list."""
416432
stderr = _refused(_env(_JWKS, VGI_JWT_AUDIENCE=f"{AUDIENCE},https://desk.orchard.test/d/other"))

‎uv.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vgi/hosted.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,36 @@ def check_environment_conflicts() -> None:
245245
refuse_in_hosted_mode("VGI_PROXY_PROOF_MODE must be off; hosted workers authenticate by Pass only.")
246246

247247

248+
#: The shortest VGI_SIGNING_KEY a hosted worker accepts.
249+
MIN_SIGNING_KEY_BYTES = 32
250+
251+
252+
def check_signing_key(signing_key: bytes | None, *, configured: bool) -> None:
253+
"""Refuse a hosted worker whose signing key isn't stable across restarts.
254+
255+
The key seals catalog opaque data and HTTP state tokens. A Field Worker's
256+
machines stop and start, and a deployment can run on several of them: a
257+
key minted per process makes every restart (and every other machine)
258+
reject the sessions DuckDB already holds.
259+
260+
Args:
261+
signing_key: The resolved key, or ``None`` if there is none.
262+
configured: Whether it was configured by the operator (``VGI_SIGNING_KEY``
263+
or passed in), rather than minted by this process or by ``vgi-serve``.
264+
265+
Raises:
266+
SystemExit: When the key is missing, minted, or shorter than 32 bytes.
267+
268+
"""
269+
if not configured or signing_key is None:
270+
refuse_in_hosted_mode(
271+
"VGI_SIGNING_KEY is not set; hosted workers need a stable key shared by every machine of the "
272+
"deployment, or every restart breaks attached sessions."
273+
)
274+
if len(signing_key) < MIN_SIGNING_KEY_BYTES:
275+
refuse_in_hosted_mode(f"VGI_SIGNING_KEY must be at least {MIN_SIGNING_KEY_BYTES} bytes.")
276+
277+
248278
def check_create_app(
249279
worker_cls: Any,
250280
*,

‎vgi/serve.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ def create_app(
334334
if hosted:
335335
from vgi import hosted as _hosted
336336

337+
_hosted.check_signing_key(signing_key, configured=signing_key_configured)
337338
_hosted.check_create_app(
338339
worker_cls,
339340
authenticate=authenticate,
@@ -1497,6 +1498,7 @@ def _serve_http(
14971498
from vgi import hosted as _hosted
14981499
from vgi.rpc_server import resolve_grant_keys
14991500

1501+
_hosted.check_signing_key(_resolve_signing_key(), configured=not signing_key_was_minted())
15001502
_hosted.check_create_app(
15011503
worker_cls,
15021504
authenticate=authenticate,

0 commit comments

Comments
 (0)