You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GET /v1/leases/{id} answers 404 on a gateway for a lease it issued #186
On a gateway, GET /v1/leases/{id} answers 404 UNKNOWN_LEASE for a live lease that gateway issued. The request resource for the same lease answers 200 and shows it granted.
Reproduction
In e2e/gateway-smoke.test.ts, test "leases and execs through a gateway over HTTP…", right after the lease request is granted:
GET /v1/leases/<leaseId> -> 404 {"error":{"code":"UNKNOWN_LEASE","message":"Unknown lease: c9e9eefd-….lse_48e0709f-…"}}
GET /v1/lease-requests/<reqId> -> 200 {"request":{"state":"granted","lease":{"id":"c9e9eefd-….lse_48e0709f-…", …}}}
Run on feature/158 (7ce701f); src/http and src/gateway are the same as main there.
Likely cause
The route finds the lease through lease.list, then looks the device up in the local registry (findDevice, src/http/app.ts). A gateway is given an empty one (registry: { snapshot: { devices: [] } } in startGatewayDaemon, src/daemon/main.ts), so the lookup misses and the route throws unknownLease. The comment beside that stub says lease routes answer UNSUPPORTED_IN_GATEWAY_MODE, which is no longer true.
Expected
The lease object, as a worker returns it and as docs/HTTP-API.md describes.
Defect. On a gateway, GET /v1/leases/{id} answers 404 UNKNOWN_LEASE for a live lease it granted. Reproduced with a fake-driver gateway and one worker.
e2e/gateway-smoke.test.ts, "serves GET /v1/leases/{id} for a lease the gateway granted over HTTP: the granted lease, naming its worker (#186)", on bug/186-repro. It expects the request resource's lease plus workerId and worker, as docs/HTTP-API.md describes a gateway lease.
src/http/app.ts:347-348. The route finds the lease through lease.list, which works on a gateway, then needs a device record from deps.registry and throws unknownLease without one. A gateway gets an empty registry (src/daemon/main.ts:765); the comment above it is false. The issue's diagnosis is right, with one correction: the worker views cannot stand in for the registry. Their devices are narrowed to statusDeviceSchema (src/gateway/worker-link.ts:110), which has no driverDeviceId, so udid would be lost. Also, buildLeasePayload (src/http/tracker.ts:60) drops worker and workerId.
Simplest fix
The gateway keeps each worker's devices in the grant shape (grantedDeviceSchema), parsed from the list.get its view refresh already makes. Not on the contract's WorkerView.
startGatewayDaemon wires that as the device reader; fix the comment.
buildLeasePayload copies worker and workerId from the lease record.
A throwaway prototype of this passed the test and the other four smoke tests.
Alternatives rejected
Views as the registry: no udid; adding it to statusDeviceSchema shows every udid to every agent.
The gateway's request book: gone after lease.requestRetentionMs and on restart.
A forwarded lease.get operation: closest to ADR 0005 §15, but a contract change; a spec session's call.
Risk
HttpRegistryReader is typed as full DeviceRecords, and DELETE /v1/leases/{id} reads state from it. Narrow the type rather than fake a state.
Lease and device come from one refresh; check a lease is never visible before its device.
Keep driverDeviceId off status.get and worker.list.
Activity
test: reproduce #186 — GET /v1/leases/{id} on a gateway serves the le…
V3RON commentedon Oct 2, 2026
Reproduction
Defect. On a gateway,
GET /v1/leases/{id}answers404 UNKNOWN_LEASEfor a live lease it granted. Reproduced with a fake-driver gateway and one worker.e2e/gateway-smoke.test.ts, "serves GET /v1/leases/{id} for a lease the gateway granted over HTTP: the granted lease, naming its worker (#186)", onbug/186-repro. It expects the request resource's lease plusworkerIdandworker, asdocs/HTTP-API.mddescribes a gateway lease.Root cause
src/http/app.ts:347-348. The route finds the lease throughlease.list, which works on a gateway, then needs a device record fromdeps.registryand throwsunknownLeasewithout one. A gateway gets an empty registry (src/daemon/main.ts:765); the comment above it is false. The issue's diagnosis is right, with one correction: the worker views cannot stand in for the registry. Their devices are narrowed tostatusDeviceSchema(src/gateway/worker-link.ts:110), which has nodriverDeviceId, soudidwould be lost. Also,buildLeasePayload(src/http/tracker.ts:60) dropsworkerandworkerId.Simplest fix
grantedDeviceSchema), parsed from thelist.getits view refresh already makes. Not on the contract'sWorkerView.startGatewayDaemonwires that as the device reader; fix the comment.buildLeasePayloadcopiesworkerandworkerIdfrom the lease record.A throwaway prototype of this passed the test and the other four smoke tests.
Alternatives rejected
udid; adding it tostatusDeviceSchemashows every udid to every agent.lease.requestRetentionMsand on restart.lease.getoperation: closest to ADR 0005 §15, but a contract change; a spec session's call.Risk
HttpRegistryReaderis typed as fullDeviceRecords, andDELETE /v1/leases/{id}readsstatefrom it. Narrow the type rather than fake a state.driverDeviceIdoffstatus.getandworker.list.Side findings
Written by an agent.