diff --git a/tools/hwlab-cli/hwpod.test.ts b/tools/hwlab-cli/hwpod.test.ts index 5c4125a0..0f56c051 100644 --- a/tools/hwlab-cli/hwpod.test.ts +++ b/tools/hwlab-cli/hwpod.test.ts @@ -200,16 +200,14 @@ test("HWPOD over-api resolves a registry spec from the API envelope", async () = let submitted: any = null; const fetchImpl = async (input: string | URL | Request, init?: RequestInit) => { const url = new URL(String(input)); - if (url.pathname === "/v1/hwpod/specs" && init?.method === "GET") { + if (url.pathname === "/v1/hwpod/specs/builtin-hwpod" && init?.method === "GET") { return Response.json({ ok: true, status: "completed", body: { - specs: [{ - hwpodId: "builtin-hwpod", - authority: "yaml-first-builtin", - document: hwpodSpecDocument("builtin-hwpod", "/builtin") - }] + hwpodId: "builtin-hwpod", + authority: "yaml-first-builtin", + document: hwpodSpecDocument("builtin-hwpod", "/builtin") } }); } diff --git a/tools/src/hwpod-harness-lib.ts b/tools/src/hwpod-harness-lib.ts index e1926a1a..44e4bb81 100644 --- a/tools/src/hwpod-harness-lib.ts +++ b/tools/src/hwpod-harness-lib.ts @@ -589,7 +589,7 @@ async function resolveHwpodDocument({ parsed, env, fetchImpl }: { parsed: Parsed async function fetchHwpodSpecById({ hwpodId, parsed, env, fetchImpl }: { hwpodId: string; parsed: ParsedArgs; env: EnvLike; fetchImpl?: FetchLike }) { const endpoint = resolveRuntimeEndpoint({ kind: "api", parsed, env }); - const route = { method: "GET", path: `/v1/hwpod/specs?hwpodId=${encodeURIComponent(hwpodId)}` }; + const route = { method: "GET", path: `/v1/hwpod/specs/${encodeURIComponent(hwpodId)}` }; const url = `${endpoint.baseUrl}${route.path}`; const headers = authHeaders(parsed, env); const response = fetchImpl @@ -598,12 +598,9 @@ async function fetchHwpodSpecById({ hwpodId, parsed, env, fetchImpl }: { hwpodId const body = await response.json().catch(() => null); if (!body || body.ok === false) throw cliError("hwpod_registry_request_failed", "failed to query HWPOD registry", { hwpodId, httpStatus: response.status, body: compactObject(body), runtimeEndpoint: runtimeEndpointVisibility(endpoint) }); const registryBody = isPlainObject(body.body) ? body.body : body; - const specs = Array.isArray(registryBody.specs) ? registryBody.specs : []; - const match = specs.find((item: any) => text(item.hwpodId) === hwpodId || text(item.name) === hwpodId || text(item.uid) === hwpodId); - if (!match) throw cliError("hwpod_id_not_found", `HWPOD id not found in runtime registry: ${hwpodId}`, { hwpodId, count: specs.length, runtimeEndpoint: runtimeEndpointVisibility(endpoint) }); - const document = objectValue(match.document); - if (!isPlainObject(document)) throw cliError("hwpod_registry_document_missing", `HWPOD registry item has no document: ${hwpodId}`, { hwpodId, item: compactObject(match) }); - return { ...match, document }; + const document = objectValue(registryBody.document); + if (!isPlainObject(document)) throw cliError("hwpod_registry_document_missing", `HWPOD registry item has no document: ${hwpodId}`, { hwpodId, item: compactObject(registryBody) }); + return { ...registryBody, document }; } function applyHwpodRuntimeOverrides(document: any, parsed: ParsedArgs, env: EnvLike, sourcePath: string) {