Merge pull request #2722 from pikasTech/fix/hwpod-registry-envelope
Pipelines as Code CI / hwlab-nc01-v03-ci-poll- Failed

fix: 按 ID 读取 HWPOD spec 文档
This commit is contained in:
Lyon
2026-07-21 09:36:25 +08:00
committed by GitHub
2 changed files with 8 additions and 13 deletions
+4 -6
View File
@@ -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")
}
});
}
+4 -7
View File
@@ -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) {