Skip to content

A gateway's lease-request resource returns the lease without workerId and worker #253

Closed

Description

@V3RON

On a gateway, the lease object in `POST /v1/lease-requests`'s `201` and in a granted `GET /v1/lease-requests/{id}` has no `workerId` and no `worker`. `docs/HTTP-API.md` ("The lease object") says a gateway-issued lease carries both.

Seen in a fake-driver gateway with one worker labelled `worker-a` (`e2e/gateway-smoke.test.ts`). The granted request's lease had exactly these keys:

```
createdAt, dataPlane, device, deviceId, expiresAt, id, mode, os, platform, requestId, ttlMs, udid
```

`buildLeasePayload` (`src/http/tracker.ts:60`) copies neither field from the lease record. The fleet grant's lease does carry `worker` (`FleetLeaseCoordinator#projectRecord`, `src/gateway/fleet-coordinator.ts:1064`) but not `workerId`, so copying alone would still leave `workerId` out.

Found while triaging #186.

Written by an agent.

Activity

  1. added
    bug:new
    on Oct 2, 2026
  2. removed
    bug:new
    on Oct 2, 2026
  3. self-assigned this
    on Oct 2, 2026
  4. V3RON commented on Oct 2, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Defect. A gateway-granted lease on the request resource has neither workerId nor worker; docs/HTTP-API.md ("The lease object") gives it both. Reproduced with a fake-driver gateway and one worker on all three paths: a granted GET, a 201 granted inline, and that request read back.

    e2e/gateway-smoke.test.ts, "returns workerId and worker on a gateway-granted lease, in POST /v1/lease-requests' 201 and in GET /v1/lease-requests/{id} (#253)", on bug/253-repro.

    pnpm run build && pnpm run build:e2e
    pnpm exec vitest run --project e2e e2e/gateway-smoke.test.ts -t "#253"
    
    AssertionError: expected { firstRequestRead: { …(12) }, …(2) } to deeply equal { …(3) }
        "secondRequestCreated": {
          "lease": {
    -       "worker": { "id": "4b247fd3-…", "label": "worker-a" },
    -       "workerId": "4b247fd3-…",
    +       "createdAt": …, "id": "4b247fd3-….lse_dd72829e-…", "udid": "fake-android-1", …
          },
          "state": "granted",
    

    Root cause

    src/http/tracker.ts:64-79: buildLeasePayload copies neither field. The grant's lease record carries worker (FleetLeaseCoordinator#projectRecord, src/gateway/fleet-coordinator.ts:1064), but its schema has no workerId (leaseRecordSchema, src/contract/schemas.ts:191); only lease.list's statusLeaseSchema (schemas.ts:884) adds one. So #186's step 3 as written, "copy worker and workerId from the lease record", fixes GET /v1/leases/{id} but leaves workerId off this resource. A prototype of that step still fails this test on workerId alone.

    Simplest fix

    In buildLeasePayload, when the lease has worker, emit worker and workerId: worker.id; the docs say workerId mirrors worker. Add worker? to HttpLeaseRecord (tracker.ts:381). A prototype passed this test, the other four smoke tests, and the src/http and src/gateway unit suites.

    Deliver it with #186, not alone: #186's step 3 edits this same line. Amend that step to the line above, carry this test into #186's PR, and close #253 as a duplicate when it merges.

    Alternatives rejected

    Risk

    • A worker's own lease must keep neither field: emit workerId only alongside worker.
    • docs/HTTP-API.md already describes the fixed shape; no doc change.

    Written by an agent.

  5. removed their assignment
    on Oct 2, 2026
  6. added
    bug:ready
    on Oct 2, 2026
  7. self-assigned this
    on Oct 2, 2026
  8. V3RON commented on Oct 2, 2026

    @V3RON
    ContributorAuthor

    Fixed by #285 (merged with #186), which carries this issue's regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions