fix(onepassword): preserve oversized token diagnostics (#108964)

This commit is contained in:
Peter Steinberger
2026-07-16 04:52:36 -07:00
committed by GitHub
parent 2d9584ccda
commit e1fda44ecc
2 changed files with 4 additions and 4 deletions

View File

@@ -127,7 +127,7 @@ describe("OpClient", () => {
client.getItem({ item: "Token", vault: "Automation", field: "credential" }),
).rejects.toMatchObject({
code: "TOKEN_MISSING",
message: "1Password service account token file is too large",
message: `1Password service account token file at ${tokenFile} exceeds 16384 bytes.`,
});
expect(runner).not.toHaveBeenCalled();
});

View File

@@ -2,9 +2,9 @@ import fsSync from "node:fs";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { extractErrorCode } from "openclaw/plugin-sdk/error-runtime";
import { runExec } from "openclaw/plugin-sdk/process-runtime";
import { tryReadSecretFileSync } from "openclaw/plugin-sdk/secret-file-runtime";
import { FsSafeError } from "openclaw/plugin-sdk/security-runtime";
import { OnePasswordError } from "./errors.js";
const MAX_STDOUT_BYTES = 1024 * 1024;
@@ -208,8 +208,8 @@ export class OpClient {
}
} catch (error) {
const message =
error instanceof FsSafeError && error.code === "too-large"
? "1Password service account token file is too large"
error instanceof Error && extractErrorCode(error) === "too-large"
? error.message
: "1Password service account token file is missing";
throw new OnePasswordError("TOKEN_MISSING", message, { cause: error });
}