惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
博客园 - Franky
IT之家
IT之家
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
腾讯CDC
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
博客园_首页
G
Google Developers Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(e2e): reject invalid client gateway ports · openclaw/...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main

File tree

    • openai-web-search-minimal

Original file line numberDiff line numberDiff line change

@@ -6,9 +6,9 @@ import { renderBitmapTextPngBase64 } from "../../../../test/helpers/live-image-p

66

import { createGatewayWsClient } from "../../../lib/gateway-ws-client.ts";

77

import { resolveGatewaySuccessPayload } from "../gateway-frame-payload.mjs";

88

import { createJsonlRequestTailer } from "./jsonl-request-tail.mjs";

9-

import { readPositiveIntEnv } from "./limits.mjs";

9+

import { readPositiveIntEnv, readTcpPortEnv } from "./limits.mjs";

1010
11-

const port = process.env.PORT;

11+

const portText = process.env.PORT;

1212

const token = process.env.OPENCLAW_GATEWAY_TOKEN;

1313

const appServerLog =

1414

process.env.OPENCLAW_CODEX_MEDIA_PATH_APP_SERVER_LOG ??

@@ -19,9 +19,10 @@ const logTailMaxBytes = readPositiveIntEnv(

1919

2 * 1024 * 1024,

2020

);

2121
22-

if (!port || !token) {

22+

if (!portText || !token) {

2323

throw new Error("missing PORT/OPENCLAW_GATEWAY_TOKEN");

2424

}

25+

const port = readTcpPortEnv("PORT", portText);

2526
2627

function assert(condition, message) {

2728

if (!condition) {

Original file line numberDiff line numberDiff line change

@@ -1,26 +1,17 @@

11

// Gateway client for OpenAI chat tools E2E scenarios.

2-

const port = process.env.PORT;

2+

import { readPositiveIntEnv, readTcpPortEnv } from "../env-limits.mjs";

3+
4+

const portText = process.env.PORT;

35

const token = process.env.OPENCLAW_GATEWAY_TOKEN;

46

const backendModel = process.env.MODEL_REF || "openai/gpt-5.4-mini";

57
6-

function readPositiveIntEnv(name, fallback) {

7-

const text = String(process.env[name] ?? fallback).trim();

8-

if (!/^\d+$/u.test(text)) {

9-

throw new Error(`invalid ${name}: ${text}`);

10-

}

11-

const value = Number(text);

12-

if (!Number.isSafeInteger(value) || value <= 0) {

13-

throw new Error(`invalid ${name}: ${text}`);

14-

}

15-

return value;

16-

}

17-
188

const timeoutSeconds = readPositiveIntEnv("OPENCLAW_OPENAI_CHAT_TOOLS_TIMEOUT_SECONDS", 180);

199

const maxBodyBytes = readPositiveIntEnv("OPENCLAW_OPENAI_CHAT_TOOLS_MAX_BODY_BYTES", 1048576);

2010
21-

if (!port || !token) {

11+

if (!portText || !token) {

2212

throw new Error("missing PORT/OPENCLAW_GATEWAY_TOKEN");

2313

}

14+

const port = readTcpPortEnv("PORT", portText);

2415

if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {

2516

throw new Error(`invalid OPENCLAW_OPENAI_CHAT_TOOLS_TIMEOUT_SECONDS: ${timeoutSeconds}`);

2617

}

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

// Client script for minimal OpenAI web-search E2E scenarios.

22

import { readdirSync } from "node:fs";

33

import { pathToFileURL } from "node:url";

4+

import { readTcpPortEnv } from "../env-limits.mjs";

45
56

async function loadCallGateway() {

67

const candidates = readdirSync("/app/dist")

@@ -24,12 +25,20 @@ function readExpectedRawSchemaError() {

2425

return process.env.RAW_SCHEMA_ERROR?.trim() || DEFAULT_RAW_SCHEMA_ERROR;

2526

}

2627
28+

function resolveGatewayPort(env = process.env) {

29+

const portText = env.PORT;

30+

if (!portText) {

31+

throw new Error("missing PORT");

32+

}

33+

return readTcpPortEnv("PORT", portText, env);

34+

}

35+
2736

async function gatewayAgent(params) {

28-

const port = process.env.PORT;

2937

const token = process.env.OPENCLAW_GATEWAY_TOKEN;

30-

if (!port || !token) {

38+

if (!token) {

3139

throw new Error("missing PORT/OPENCLAW_GATEWAY_TOKEN");

3240

}

41+

const port = resolveGatewayPort();

3342
3443

try {

3544

const callGateway = await loadCallGateway();

@@ -186,6 +195,7 @@ export const testing = {

186195

DEFAULT_RAW_SCHEMA_ERROR,

187196

SUCCESS_MARKER,

188197

extractSuccessReplyTexts,

198+

resolveGatewayPort,

189199

validateSuccessResult,

190200

validateRejectResult,

191201

};

Original file line numberDiff line numberDiff line change

@@ -5,7 +5,10 @@ import { tmpdir } from "node:os";

55

import path from "node:path";

66

import { afterEach, describe, expect, it } from "vitest";

77

import { createJsonlRequestTailer } from "../../scripts/e2e/lib/codex-media-path/jsonl-request-tail.mjs";

8-

import { readPositiveIntEnv } from "../../scripts/e2e/lib/codex-media-path/limits.mjs";

8+

import {

9+

readPositiveIntEnv,

10+

readTcpPortEnv,

11+

} from "../../scripts/e2e/lib/codex-media-path/limits.mjs";

912

import { createBoundedChildOutput } from "../helpers/bounded-child-output.js";

1013
1114

const tempRoots: string[] = [];

@@ -106,6 +109,10 @@ describe("codex media path limits", () => {

106109

).toThrow("invalid OPENCLAW_CODEX_MEDIA_PATH_LOG_TAIL_MAX_BYTES: 64bytes");

107110

});

108111
112+

it("rejects out-of-range TCP ports", () => {

113+

expect(() => readTcpPortEnv("PORT", 18790, { PORT: "65536" })).toThrow("invalid PORT: 65536");

114+

});

115+
109116

it("writes strict positive timeout and port values into generated config", () => {

110117

const root = makeTempRoot();

111118

const result = runWriteConfig(root, {

Original file line numberDiff line numberDiff line change

@@ -35,7 +35,7 @@ async function listen(server: Server): Promise<number> {

3535

}

3636
3737

function runClient(

38-

port: number,

38+

port: number | string,

3939

env: Record<string, string> = {},

4040

timeout = 5_000,

4141

): Promise<ClientResult> {

@@ -222,6 +222,13 @@ describe("scripts/e2e/lib/openai-chat-tools/client.mjs", () => {

222222

expect(result.stderr).toContain("invalid OPENCLAW_OPENAI_CHAT_TOOLS_MAX_BODY_BYTES: 64bytes");

223223

});

224224
225+

it("rejects out-of-range client gateway ports", async () => {

226+

const result = await runClient("65536");

227+
228+

expect(result.status).not.toBe(0);

229+

expect(result.stderr).toContain("invalid PORT: 65536");

230+

});

231+
225232

it("rejects loose write-config timeout env values", () => {

226233

const root = mkdtempSync(path.join(tmpdir(), "openclaw-openai-chat-tools-"));

227234

try {

Original file line numberDiff line numberDiff line change

@@ -41,6 +41,10 @@ describe("scripts/e2e/lib/openai-web-search-minimal/client.mjs", () => {

4141

).toThrow(/reject mode failed for an unexpected reason/u);

4242

});

4343
44+

it("rejects out-of-range gateway ports before connecting", () => {

45+

expect(() => testing.resolveGatewayPort({ PORT: "65536" })).toThrow("invalid PORT: 65536");

46+

});

47+
4448

it("accepts success mode only when the final assistant reply contains the marker", () => {

4549

expect(() =>

4650

testing.validateSuccessResult({