Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions plugins/openclaw/openclaw/__tests__/http-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ describe("Group 3: Cloud API Communication", () => {
expect(result.instance_id).toBe("i-1");
});

it.each([
["an object without status", { instance_id: "i-1", db: true }],
["an empty status", { status: " ", instance_id: "i-1", db: true }],
["a non-object response", "ok"],
])("3.29a healthCheck rejects %s", async (_description, response) => {
fetchMock.respondWith(200, response);

await expect(transport.healthCheck()).rejects.toThrow(/invalid health response/i);
});

it("3.30 unknown tool throws", async () => {
await expect(transport.callTool("memory_nonexistent", {}))
.rejects.toThrow(/Unknown Memoria tool/);
Expand Down
6 changes: 5 additions & 1 deletion plugins/openclaw/openclaw/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,12 @@ export class MemoriaHttpTransport {
async healthCheck(): Promise<{ status: string; instance_id?: string; db?: boolean }> {
const data = await this.get("/health/instance");
const rec = this.asRecord(data);
const status = typeof rec?.status === "string" ? rec.status.trim() : "";
if (!status) {
throw new Error("Invalid health response: missing status");
}
return {
status: typeof rec?.status === "string" ? rec.status : "ok",
status,
instance_id: typeof rec?.instance_id === "string" ? rec.instance_id : undefined,
db: typeof rec?.db === "boolean" ? rec.db : undefined,
};
Expand Down
Loading