mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:00:44 +00:00
fix: accept lowercase channel env triggers
This commit is contained in:
@@ -119,7 +119,7 @@ function createManifestRegistryFixture() {
|
||||
id: "ambient-env-channel-plugin",
|
||||
channels: ["ambient-env-channel"],
|
||||
channelEnvVars: {
|
||||
"ambient-env-channel": ["HOME", "PATH", "lowercase_token"],
|
||||
"ambient-env-channel": ["HOME", "PATH"],
|
||||
},
|
||||
origin: "config",
|
||||
enabledByDefault: undefined,
|
||||
@@ -715,6 +715,66 @@ describe("listConfiguredChannelIdsForReadOnlyScope", () => {
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("accepts lowercase or mixed-case manifest env vars as read-only configured channel triggers", () => {
|
||||
expect(
|
||||
listConfiguredChannelIdsForReadOnlyScope({
|
||||
config: {
|
||||
plugins: {
|
||||
allow: ["external-env-channel-plugin"],
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
workspaceDir: "/tmp",
|
||||
env: {
|
||||
external_env_channel_token: "token",
|
||||
} as NodeJS.ProcessEnv,
|
||||
includePersistedAuthState: false,
|
||||
manifestRecords: [
|
||||
{
|
||||
id: "external-env-channel-plugin",
|
||||
channels: ["external-env-channel"],
|
||||
channelEnvVars: {
|
||||
"external-env-channel": ["external_env_channel_token"],
|
||||
},
|
||||
origin: "config",
|
||||
enabledByDefault: undefined,
|
||||
providers: [],
|
||||
cliBackends: [],
|
||||
} as never,
|
||||
],
|
||||
}),
|
||||
).toEqual(["external-env-channel"]);
|
||||
});
|
||||
|
||||
it("matches uppercase process env entries for lowercase manifest env var declarations", () => {
|
||||
expect(
|
||||
listConfiguredChannelIdsForReadOnlyScope({
|
||||
config: {
|
||||
plugins: {
|
||||
allow: ["external-env-channel-plugin"],
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
workspaceDir: "/tmp",
|
||||
env: {
|
||||
EXTERNAL_ENV_CHANNEL_TOKEN: "token",
|
||||
} as NodeJS.ProcessEnv,
|
||||
includePersistedAuthState: false,
|
||||
manifestRecords: [
|
||||
{
|
||||
id: "external-env-channel-plugin",
|
||||
channels: ["external-env-channel"],
|
||||
channelEnvVars: {
|
||||
"external-env-channel": ["external_env_channel_token"],
|
||||
},
|
||||
origin: "config",
|
||||
enabledByDefault: undefined,
|
||||
providers: [],
|
||||
cliBackends: [],
|
||||
} as never,
|
||||
],
|
||||
}),
|
||||
).toEqual(["external-env-channel"]);
|
||||
});
|
||||
|
||||
it("uses manifest env vars for read-only channel presence checks", () => {
|
||||
listPotentialConfiguredChannelIds.mockReturnValue([]);
|
||||
hasPotentialConfiguredChannels.mockReturnValue(false);
|
||||
|
||||
@@ -70,7 +70,8 @@ function hasNonEmptyEnvValue(env: NodeJS.ProcessEnv, key: string): boolean {
|
||||
if (!isSafeChannelEnvVarTriggerName(key)) {
|
||||
return false;
|
||||
}
|
||||
const value = env[key];
|
||||
const trimmed = key.trim();
|
||||
const value = env[trimmed] ?? env[trimmed.toUpperCase()];
|
||||
return typeof value === "string" && value.trim().length > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ const UNSAFE_CHANNEL_ENV_VAR_TRIGGER_NAMES = new Set([
|
||||
]);
|
||||
|
||||
export function isSafeChannelEnvVarTriggerName(key: string): boolean {
|
||||
const normalized = key.trim();
|
||||
const normalized = key.trim().toUpperCase();
|
||||
return (
|
||||
/^[A-Z][A-Z0-9_]*$/.test(normalized) && !UNSAFE_CHANNEL_ENV_VAR_TRIGGER_NAMES.has(normalized)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user