Skip to content

Slack: fix missing directory helper import#49930

Merged
scoootscooob merged 1 commit intoopenclaw:mainfrom
scoootscooob:codex/fix-slack-directory-import
Mar 18, 2026
Merged

Slack: fix missing directory helper import#49930
scoootscooob merged 1 commit intoopenclaw:mainfrom
scoootscooob:codex/fix-slack-directory-import

Conversation

@scoootscooob
Copy link
Copy Markdown
Contributor

Summary

  • import the Slack directory config helpers into the channel plugin so directory.listPeers and directory.listGroups do not throw at runtime
  • add a regression test that exercises slackPlugin.directory.listPeers against configured Slack DMs

Validation

  • pnpm test -- extensions/slack/src/channel.test.ts

Notes

  • This addresses a real runtime failure: the directory methods referenced bare identifiers that were never imported.

@openclaw-barnacle openclaw-barnacle bot added channel: slack Channel integration: slack size: XS maintainer Maintainer-authored PR labels Mar 18, 2026
@scoootscooob scoootscooob self-assigned this Mar 18, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR fixes a runtime ReferenceError in the Slack channel plugin by adding the missing import of listSlackDirectoryPeersFromConfig and listSlackDirectoryGroupsFromConfig from ./directory-config.js — both functions were already wired into slackPlugin.directory.listPeers and slackPlugin.directory.listGroups but were never imported, so any call to those methods would throw immediately.

  • Core fix (channel.ts): adds the two named imports from ./directory-config.js. The target module exists and exports both symbols. Worth noting: runtime-api.ts already re-exports these same symbols, so they could alternatively have been pulled from the existing ./runtime-api.js import block in channel.ts, keeping import sources more consolidated — but the direct import is equally valid.
  • Regression test (channel.test.ts): adds a "slackPlugin directory" describe block that calls listPeers against a minimal DM config and asserts the normalized result. The test correctly exercises the previously-broken code path. However, listGroups (the other function fixed by this PR) does not yet have a regression test.
  • No logic changes are introduced; the fix is purely an import correction.

Confidence Score: 4/5

  • Safe to merge — the change is a minimal, targeted import fix with no logic modifications and a passing regression test.
  • The fix is correct and the import path verified against the actual exported symbols. The only minor gaps are a style preference for import consolidation and missing test coverage for listGroups, neither of which affects correctness or safety.
  • No files require special attention.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/slack/src/channel.ts
Line: 24-27

Comment:
**Alternative: import from existing `runtime-api.js` re-export**

`runtime-api.ts` already re-exports both `listSlackDirectoryPeersFromConfig` and `listSlackDirectoryGroupsFromConfig` from `./directory-config.js` (lines 12–15 in `runtime-api.ts`). Adding these two names to the existing `runtime-api.js` import block in `channel.ts` (which already imports several sibling utilities from there) would consolidate imports and avoid introducing a new import source for a file that is otherwise accessed through `runtime-api`.

```suggestion
import {
  buildComputedAccountStatusSnapshot,
  DEFAULT_ACCOUNT_ID,
  listSlackDirectoryGroupsFromConfig,
  listSlackDirectoryPeersFromConfig,
  looksLikeSlackTargetId,
  normalizeSlackMessagingTarget,
  PAIRING_APPROVED_MESSAGE,
  projectCredentialSnapshotFields,
  resolveConfiguredFromRequiredCredentialStatuses,
  type ChannelPlugin,
  type OpenClawConfig,
} from "./runtime-api.js";
```
(and remove the separate `./directory-config.js` import block)

This is purely a style suggestion — the current direct import is functionally correct.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/slack/src/channel.test.ts
Line: 174-194

Comment:
**`listGroups` has no regression coverage**

The PR description mentions that both `directory.listPeers` and `directory.listGroups` threw at runtime due to the missing import. The new test only exercises `listPeers`. A parallel test for `listGroups` (using `channels` keys instead of `dms` keys) would close the regression gap for the second fixed path and guard against the same issue re-appearing for groups.

```suggestion
  it("lists configured groups without throwing a ReferenceError", async () => {
    const listGroups = slackPlugin.directory?.listGroups;
    expect(listGroups).toBeDefined();

    await expect(
      listGroups!({
        cfg: {
          channels: {
            slack: {
              channels: {
                "C456": {},
              },
            },
          },
        },
        runtime: undefined,
      }),
    ).resolves.toBeDefined();
  });
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "Slack: import direct..."

Comment on lines +24 to +27
import {
listSlackDirectoryGroupsFromConfig,
listSlackDirectoryPeersFromConfig,
} from "./directory-config.js";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Alternative: import from existing runtime-api.js re-export

runtime-api.ts already re-exports both listSlackDirectoryPeersFromConfig and listSlackDirectoryGroupsFromConfig from ./directory-config.js (lines 12–15 in runtime-api.ts). Adding these two names to the existing runtime-api.js import block in channel.ts (which already imports several sibling utilities from there) would consolidate imports and avoid introducing a new import source for a file that is otherwise accessed through runtime-api.

Suggested change
import {
listSlackDirectoryGroupsFromConfig,
listSlackDirectoryPeersFromConfig,
} from "./directory-config.js";
import {
buildComputedAccountStatusSnapshot,
DEFAULT_ACCOUNT_ID,
listSlackDirectoryGroupsFromConfig,
listSlackDirectoryPeersFromConfig,
looksLikeSlackTargetId,
normalizeSlackMessagingTarget,
PAIRING_APPROVED_MESSAGE,
projectCredentialSnapshotFields,
resolveConfiguredFromRequiredCredentialStatuses,
type ChannelPlugin,
type OpenClawConfig,
} from "./runtime-api.js";

(and remove the separate ./directory-config.js import block)

This is purely a style suggestion — the current direct import is functionally correct.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/slack/src/channel.ts
Line: 24-27

Comment:
**Alternative: import from existing `runtime-api.js` re-export**

`runtime-api.ts` already re-exports both `listSlackDirectoryPeersFromConfig` and `listSlackDirectoryGroupsFromConfig` from `./directory-config.js` (lines 12–15 in `runtime-api.ts`). Adding these two names to the existing `runtime-api.js` import block in `channel.ts` (which already imports several sibling utilities from there) would consolidate imports and avoid introducing a new import source for a file that is otherwise accessed through `runtime-api`.

```suggestion
import {
  buildComputedAccountStatusSnapshot,
  DEFAULT_ACCOUNT_ID,
  listSlackDirectoryGroupsFromConfig,
  listSlackDirectoryPeersFromConfig,
  looksLikeSlackTargetId,
  normalizeSlackMessagingTarget,
  PAIRING_APPROVED_MESSAGE,
  projectCredentialSnapshotFields,
  resolveConfiguredFromRequiredCredentialStatuses,
  type ChannelPlugin,
  type OpenClawConfig,
} from "./runtime-api.js";
```
(and remove the separate `./directory-config.js` import block)

This is purely a style suggestion — the current direct import is functionally correct.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +174 to +194
describe("slackPlugin directory", () => {
it("lists configured peers without throwing a ReferenceError", async () => {
const listPeers = slackPlugin.directory?.listPeers;
expect(listPeers).toBeDefined();

await expect(
listPeers!({
cfg: {
channels: {
slack: {
dms: {
U123: {},
},
},
},
},
runtime: undefined,
}),
).resolves.toEqual([{ id: "user:u123", kind: "user" }]);
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 listGroups has no regression coverage

The PR description mentions that both directory.listPeers and directory.listGroups threw at runtime due to the missing import. The new test only exercises listPeers. A parallel test for listGroups (using channels keys instead of dms keys) would close the regression gap for the second fixed path and guard against the same issue re-appearing for groups.

Suggested change
describe("slackPlugin directory", () => {
it("lists configured peers without throwing a ReferenceError", async () => {
const listPeers = slackPlugin.directory?.listPeers;
expect(listPeers).toBeDefined();
await expect(
listPeers!({
cfg: {
channels: {
slack: {
dms: {
U123: {},
},
},
},
},
runtime: undefined,
}),
).resolves.toEqual([{ id: "user:u123", kind: "user" }]);
});
});
it("lists configured groups without throwing a ReferenceError", async () => {
const listGroups = slackPlugin.directory?.listGroups;
expect(listGroups).toBeDefined();
await expect(
listGroups!({
cfg: {
channels: {
slack: {
channels: {
"C456": {},
},
},
},
},
runtime: undefined,
}),
).resolves.toBeDefined();
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/slack/src/channel.test.ts
Line: 174-194

Comment:
**`listGroups` has no regression coverage**

The PR description mentions that both `directory.listPeers` and `directory.listGroups` threw at runtime due to the missing import. The new test only exercises `listPeers`. A parallel test for `listGroups` (using `channels` keys instead of `dms` keys) would close the regression gap for the second fixed path and guard against the same issue re-appearing for groups.

```suggestion
  it("lists configured groups without throwing a ReferenceError", async () => {
    const listGroups = slackPlugin.directory?.listGroups;
    expect(listGroups).toBeDefined();

    await expect(
      listGroups!({
        cfg: {
          channels: {
            slack: {
              channels: {
                "C456": {},
              },
            },
          },
        },
        runtime: undefined,
      }),
    ).resolves.toBeDefined();
  });
```

How can I resolve this? If you propose a fix, please make it concise.

@scoootscooob scoootscooob merged commit b49946a into openclaw:main Mar 18, 2026
30 of 45 checks passed
livingghost pushed a commit to livingghost/openclaw that referenced this pull request Mar 18, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
livingghost pushed a commit to livingghost/openclaw that referenced this pull request Mar 18, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
livingghost pushed a commit to livingghost/openclaw that referenced this pull request Mar 18, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
brandontyler pushed a commit to brandontyler/clawdbot that referenced this pull request Mar 19, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
udftd pushed a commit to udftd/openclaw that referenced this pull request Mar 20, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
fuller-stack-dev pushed a commit to fuller-stack-dev/openclaw that referenced this pull request Mar 20, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
fuller-stack-dev pushed a commit to fuller-stack-dev/openclaw that referenced this pull request Mar 20, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
pholpaphankorn pushed a commit to pholpaphankorn/openclaw that referenced this pull request Mar 22, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
fugue1987 pushed a commit to fugue1987/openclaw that referenced this pull request Mar 22, 2026
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant