mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-09 11:34:16 +00:00
fix(release): reject loose Docker package timeouts
This commit is contained in:
@@ -53,11 +53,14 @@ function resolveTimeoutMs(envName, defaultValue) {
|
||||
if (raw === undefined || raw === "") {
|
||||
return defaultValue;
|
||||
}
|
||||
const parsed = Number(raw);
|
||||
if (!Number.isFinite(parsed) || parsed <= 0) {
|
||||
if (!/^[0-9]+$/u.test(raw)) {
|
||||
throw new Error(`${envName} must be a positive timeout in milliseconds`);
|
||||
}
|
||||
return Math.trunc(parsed);
|
||||
const parsed = Number(raw);
|
||||
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
||||
throw new Error(`${envName} must be a positive timeout in milliseconds`);
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function readOptionValue(argv, index, optionName) {
|
||||
|
||||
@@ -146,6 +146,29 @@ describe("package-openclaw-for-docker", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects loose package artifact timeout env values", async () => {
|
||||
const previousTimeout = process.env.OPENCLAW_DOCKER_PACKAGE_BUILD_TIMEOUT_MS;
|
||||
try {
|
||||
for (const value of ["1e3", "123.9", "9007199254740993", "0"]) {
|
||||
process.env.OPENCLAW_DOCKER_PACKAGE_BUILD_TIMEOUT_MS = value;
|
||||
|
||||
await expect(
|
||||
buildPackageArtifacts("/repo", {
|
||||
runImpl: async () => undefined,
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
"OPENCLAW_DOCKER_PACKAGE_BUILD_TIMEOUT_MS must be a positive timeout in milliseconds",
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (previousTimeout === undefined) {
|
||||
delete process.env.OPENCLAW_DOCKER_PACKAGE_BUILD_TIMEOUT_MS;
|
||||
} else {
|
||||
process.env.OPENCLAW_DOCKER_PACKAGE_BUILD_TIMEOUT_MS = previousTimeout;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("trims and restores the changelog around ignore-scripts package artifacts", async () => {
|
||||
const calls: string[] = [];
|
||||
const tarball = await packOpenClawPackageForDocker("/repo", "/out", {
|
||||
|
||||
Reference in New Issue
Block a user