mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-01 12:21:25 +00:00
fix(feishu): avoid false-positive status for missing env appId refs (openclaw#30903) thanks @LiaoyuanNing
This commit is contained in:
@@ -60,6 +60,41 @@ describe("feishuOnboardingAdapter.getStatus", () => {
|
||||
expect(status.configured).toBe(false);
|
||||
});
|
||||
|
||||
it("treats env SecretRef appId as not configured when env var is missing", async () => {
|
||||
const appIdKey = "FEISHU_APP_ID_STATUS_MISSING_TEST";
|
||||
const appSecretKey = "FEISHU_APP_SECRET_STATUS_MISSING_TEST";
|
||||
const prevAppId = process.env[appIdKey];
|
||||
const prevAppSecret = process.env[appSecretKey];
|
||||
delete process.env[appIdKey];
|
||||
process.env[appSecretKey] = "secret_env_456";
|
||||
|
||||
try {
|
||||
const status = await feishuOnboardingAdapter.getStatus({
|
||||
cfg: {
|
||||
channels: {
|
||||
feishu: {
|
||||
appId: { source: "env", id: appIdKey, provider: "default" },
|
||||
appSecret: { source: "env", id: appSecretKey, provider: "default" },
|
||||
},
|
||||
},
|
||||
} as never,
|
||||
});
|
||||
|
||||
expect(status.configured).toBe(false);
|
||||
} finally {
|
||||
if (prevAppId === undefined) {
|
||||
delete process.env[appIdKey];
|
||||
} else {
|
||||
process.env[appIdKey] = prevAppId;
|
||||
}
|
||||
if (prevAppSecret === undefined) {
|
||||
delete process.env[appSecretKey];
|
||||
} else {
|
||||
process.env[appSecretKey] = prevAppSecret;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("treats env SecretRef appId/appSecret as configured in status", async () => {
|
||||
const appIdKey = "FEISHU_APP_ID_STATUS_TEST";
|
||||
const appSecretKey = "FEISHU_APP_SECRET_STATUS_TEST";
|
||||
|
||||
@@ -178,8 +178,22 @@ export const feishuOnboardingAdapter: ChannelOnboardingAdapter = {
|
||||
getStatus: async ({ cfg }) => {
|
||||
const feishuCfg = cfg.channels?.feishu as FeishuConfig | undefined;
|
||||
|
||||
const isAppIdConfigured = (value: unknown): boolean =>
|
||||
Boolean(normalizeString(value) || hasConfiguredSecretInput(value));
|
||||
const isAppIdConfigured = (value: unknown): boolean => {
|
||||
const asString = normalizeString(value);
|
||||
if (asString) {
|
||||
return true;
|
||||
}
|
||||
if (!value || typeof value !== "object") {
|
||||
return false;
|
||||
}
|
||||
const rec = value as Record<string, unknown>;
|
||||
const source = normalizeString(rec.source)?.toLowerCase();
|
||||
const id = normalizeString(rec.id);
|
||||
if (source === "env" && id) {
|
||||
return Boolean(normalizeString(process.env[id]));
|
||||
}
|
||||
return hasConfiguredSecretInput(value);
|
||||
};
|
||||
|
||||
const topLevelConfigured = Boolean(
|
||||
isAppIdConfigured(feishuCfg?.appId) && hasConfiguredSecretInput(feishuCfg?.appSecret),
|
||||
|
||||
Reference in New Issue
Block a user