Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(channel-reader,control-ui): stop an empty provider array hiding a channel's real providers

Jose Ramirez9f1a2117926e
diff --git a/channel-reader/package-lock.json b/channel-reader/package-lock.json
index a2bb6529a..656e07c41 100644
--- a/channel-reader/package-lock.json
+++ b/channel-reader/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-channel-reader",
- "version": "0.1.101",
+ "version": "0.1.102",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-channel-reader",
- "version": "0.1.101",
+ "version": "0.1.102",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@kubernetes/client-node": "^1.0.0",
diff --git a/channel-reader/package.json b/channel-reader/package.json
index 92b6e2a83..caefa522b 100644
--- a/channel-reader/package.json
+++ b/channel-reader/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-channel-reader",
- "version": "0.1.101",
+ "version": "0.1.102",
"description": "Watches CommunicationChannel CRDs and fetches messages from Telegram, Email, and Slack",
"main": "dist/main.js",
"engines": {
diff --git a/channel-reader/src/__tests__/main.test.ts b/channel-reader/src/__tests__/main.test.ts
index c69b13483..0907cfc45 100644
--- a/channel-reader/src/__tests__/main.test.ts
+++ b/channel-reader/src/__tests__/main.test.ts
@@ -1239,3 +1239,54 @@ describe('ChannelReader cron result delivery', () => {
expect(rpc.acknowledgeCronResult).not.toHaveBeenCalled()
})
})
+
+describe('ChannelReader pollCycle provider guards', () => {
+ // control-ui's create page writes every provider array on every channel, so a
+ // Teams or Slack channel arrives carrying `telegram: []`. An empty array is
+ // truthy, so the telegram branch used to run for those channels, find no
+ // telegram adapter, and `continue` -- skipping every remaining provider on the
+ // same channel. The empty array means "no telegram groups to poll", not "this
+ // is a telegram channel".
+ it('still polls other providers on a channel that carries an empty telegram array', async () => {
+ const emailAdapter = {
+ fetchMessages: vi.fn(async () => [
+ {
+ channelType: 'email' as const,
+ channelId: 'inbox-1',
+ sender: '[email protected]',
+ content: 'hello',
+ timestamp: new Date('2026-08-17T12:00:00.000Z'),
+ messageId: 'email-1',
+ },
+ ]),
+ sendMessage: vi.fn(async () => undefined),
+ }
+
+ const reader = new ChannelReader({
+ rpcClient: rpcClient(),
+ notificationDeliveryClient: null,
+ adapters: new Map([['email', emailAdapter as unknown as ChannelAdapter]]),
+ })
+ ;(reader as unknown as { channels: unknown[] }).channels = [
+ {
+ name: 'evenfire-teams-jose',
+ namespace: 'channels',
+ spec: {
+ hostRef: 'agentjose',
+ telegram: [],
+ email: [{ channelId: 'inbox-1', emails: ['[email protected]'] }],
+ teamsSettings: {
+ appId: 'a2dad48d-1b07-4b53-b177-35820f4306d3',
+ tenantId: '18517e81-9d09-4c73-88f3-e84a6c90c3d9',
+ appName: 'evenfire-teams-jose',
+ },
+ },
+ },
+ ]
+
+ const messages = await reader.pollCycle()
+
+ expect(emailAdapter.fetchMessages).toHaveBeenCalledOnce()
+ expect(messages).toHaveLength(1)
+ })
+})
diff --git a/channel-reader/src/main.ts b/channel-reader/src/main.ts
index 98b3e377a..681609315 100644
--- a/channel-reader/src/main.ts
+++ b/channel-reader/src/main.ts
@@ -1260,7 +1260,14 @@ export class ChannelReader {
const { spec } = channelCRD
// Process Telegram private chats, groups, and supergroups. Personal identity is verified separately.
- if (spec.telegram) {
+ //
+ // Guard on length, not presence. control-ui writes every provider array on
+ // every channel, so a Teams or Slack channel arrives carrying `telegram: []`.
+ // An empty array is truthy, so this branch used to run for those channels,
+ // fail to find a telegram adapter, and `continue` -- skipping every
+ // remaining provider on the same channel. An empty array means "no telegram
+ // groups to poll", not "this is a telegram channel".
+ if (spec.telegram?.length) {
const adapter = this.adapterForChannel('telegram', channelCRD)
if (!adapter) continue
const providerTarget = providerTargetFromChannel(channelCRD)
@@ -1341,8 +1348,8 @@ export class ChannelReader {
}
}
- // Process Email groups
- if (spec.email) {
+ // Process Email groups. Same empty-array reasoning as the telegram guard above.
+ if (spec.email?.length) {
const adapter = this.adapterForChannel('email', channelCRD)
if (!adapter) continue
for (const group of spec.email) {
diff --git a/control-ui/app/communication-channels/new/page.tsx b/control-ui/app/communication-channels/new/page.tsx
index 0a48db1f8..faff526be 100644
--- a/control-ui/app/communication-channels/new/page.tsx
+++ b/control-ui/app/communication-channels/new/page.tsx
@@ -106,6 +106,22 @@ function credentialLabel(key: keyof CredentialDraft): string {
}
}
+/**
+ * Spec fields for the selected provider, and only that provider.
+ *
+ * This deliberately does not emit empty arrays for the providers that were not
+ * selected. channel-reader guards its polling branches on the presence of the
+ * provider array, and `[]` is truthy, so a Teams channel carrying `telegram: []`
+ * entered the telegram branch, found no telegram adapter, and skipped every
+ * remaining provider on that channel. Sending only the chosen provider keeps a
+ * channel's spec an honest description of what it is.
+ *
+ * This is the create payload, so there is nothing to clear: a POST builds a
+ * fresh spec, and control-api validates each array only when it is present
+ * (`if (Array.isArray(...))`). An edit flow that has to unset a previously
+ * configured provider needs its own explicit empty array and must not rely on
+ * this helper.
+ */
function providerSettings(provider: ChannelProvider, draft: DraftState) {
if (provider === 'telegram') {
return {
@@ -114,12 +130,10 @@ function providerSettings(provider: ChannelProvider, draft: DraftState) {
botHandle: draft.telegramBotHandle.trim(),
replyOnlyWhenMentioned: draft.telegramReplyOnlyWhenMentioned,
},
- slack: [],
}
}
if (provider === 'slack') {
return {
- telegram: [],
slack: [],
slackSettings: {
botHandle: draft.slackBotHandle.trim(),
@@ -129,8 +143,6 @@ function providerSettings(provider: ChannelProvider, draft: DraftState) {
}
}
return {
- telegram: [],
- slack: [],
teams: [],
teamsSettings: {
appName: draft.teamsAppName.trim(),
diff --git a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
index 5ede1c6ac..cfb62c523 100644
--- a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
+++ b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
@@ -513,6 +513,39 @@ describe('CreateCommunicationChannelPage — provider setup', () => {
)
})
+ it('sends only the selected provider, not empty arrays for the other two', async () => {
+ render(
+ <ToastProvider>
+ <CreateCommunicationChannelPage />
+ </ToastProvider>
+ )
+
+ await fillStep1AndContinue()
+ fireEvent.click(screen.getByRole('radio', { name: 'Microsoft Teams' }))
+ fireEvent.change(screen.getByLabelText(/^Name/), { target: { value: 'Evenfire Bot' } })
+ fireEvent.change(screen.getByLabelText(/^CLIENT_ID/), {
+ target: { value: '7e9cdb6c-87e8-4b1e-b291-76f7b8bdbe82' },
+ })
+ fireEvent.change(screen.getByLabelText(/^TENANT_ID/), {
+ target: { value: '21e08d37-8d53-4144-87cb-557b8298aed3' },
+ })
+ fireEvent.change(screen.getByLabelText('CLIENT_SECRET'), { target: { value: 'secret' } })
+ fireEvent.click(screen.getByRole('button', { name: 'Create channel' }))
+
+ await waitFor(() => expect(api.apiSend).toHaveBeenCalled())
+ const body = vi.mocked(api.apiSend).mock.calls[0][2] as { spec: Record<string, unknown> }
+ const specKeys = Object.keys(body.spec)
+
+ // A Teams channel used to ship `telegram: []` and `slack: []` too. Those are
+ // truthy in channel-reader's provider guards, which made it treat the channel
+ // as a misconfigured Telegram channel and skip its real providers.
+ expect(specKeys).toContain('teamsSettings')
+ expect(specKeys).not.toContain('telegram')
+ expect(specKeys).not.toContain('telegramSettings')
+ expect(specKeys).not.toContain('slack')
+ expect(specKeys).not.toContain('slackSettings')
+ })
+
it('prefills copied access and agent while creating the selected provider', async () => {
mockSearchParams.set('copyFrom', 'source-channel')
mockSearchParams.set('provider', 'slack')
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 979369aee..c10d2a887 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.430",
+ "version": "0.1.431",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.430",
+ "version": "0.1.431",
"dependencies": {
"@clerum/llm-providers": "file:../packages/llm-providers",
"@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",
diff --git a/control-ui/package.json b/control-ui/package.json
index c97ac59cd..83fd4ae13 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.430",
+ "version": "0.1.431",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",