fix(feishu): avoid false-positive status for missing env appId refs (openclaw#30903) thanks @LiaoyuanNing

This commit is contained in:
LiaoyuanNing
2026-03-03 23:51:27 +08:00
committed by joshavant
parent 05ab9bae8c
commit 4bc9e7c8c3
2 changed files with 51 additions and 2 deletions

View File

@@ -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";

View File

@@ -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),