chore: remove console_gateway_url remnants from schema and tests

Field was replaced by region+site gateway resolution but ConfigFile
definition, parseConfigFile logic, and test case were left behind.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
lishengzxc
2026-06-15 01:01:26 +08:00
parent 270412d146
commit f45b19c261
2 changed files with 3 additions and 7 deletions
+2 -5
View File
@@ -31,7 +31,6 @@ export interface ConfigFile {
access_key_id?: string;
access_key_secret?: string;
workspace_id?: string;
console_gateway_url?: string;
console_site?: "domestic" | "international";
console_region?: string;
console_switch_agent?: number;
@@ -43,8 +42,8 @@ const VALID_OUTPUTS = new Set<string>(["text", "json"]);
const VALID_CONSOLE_SITES = new Set<string>(["domestic", "international"]);
/**
* A syntactically valid absolute http(s) URL. Used to validate `base_url` and
* `console_gateway_url` from the config file: the credential-bearing client
* A syntactically valid absolute http(s) URL. Used to validate `base_url`
* from the config file: the credential-bearing client
* sends the Bearer token to these origins, so a bare `startsWith("http")` check
* (which also accepts e.g. "httpfoo://…") is too loose.
*/
@@ -91,8 +90,6 @@ export function parseConfigFile(raw: unknown): ConfigFile {
out.access_key_secret = obj.access_key_secret;
if (typeof obj.workspace_id === "string" && obj.workspace_id.length > 0)
out.workspace_id = obj.workspace_id;
if (typeof obj.console_gateway_url === "string" && isHttpUrl(obj.console_gateway_url))
out.console_gateway_url = obj.console_gateway_url;
if (typeof obj.console_site === "string" && VALID_CONSOLE_SITES.has(obj.console_site))
out.console_site = obj.console_site as ConfigFile["console_site"];
if (typeof obj.console_region === "string" && obj.console_region.length > 0)
+1 -2
View File
@@ -199,7 +199,7 @@ test("parseBooleanValue accepts only true and false strings (case-insensitive)",
expect(() => parseBooleanValue("maybe")).toThrow(BailianError);
});
test("parseConfigFile accepts only well-formed http(s) base_url / console_gateway_url", () => {
test("parseConfigFile accepts only well-formed http(s) base_url", () => {
expect(parseConfigFile({ base_url: "https://dashscope.aliyuncs.com" }).base_url).toBe(
"https://dashscope.aliyuncs.com",
);
@@ -209,5 +209,4 @@ test("parseConfigFile accepts only well-formed http(s) base_url / console_gatewa
// Previously accepted because the value merely "starts with http".
expect(parseConfigFile({ base_url: "httpfoo://evil" }).base_url).toBeUndefined();
expect(parseConfigFile({ base_url: "not a url" }).base_url).toBeUndefined();
expect(parseConfigFile({ console_gateway_url: "ftp://x" }).console_gateway_url).toBeUndefined();
});