Slack: validate runtime blocks in send and edit paths#18416
Closed
Solvely-Colin wants to merge 1 commit into
Closed
Slack: validate runtime blocks in send and edit paths#18416Solvely-Colin wants to merge 1 commit into
Solvely-Colin wants to merge 1 commit into
Conversation
Comment on lines
+361
to
+374
| const viewClosed = ( | ||
| ctx.app as unknown as { | ||
| viewClosed?: ( | ||
| matcher: RegExp, | ||
| handler: (args: { ack: () => Promise<void>; body: unknown }) => Promise<void>, | ||
| ) => void; | ||
| } | ||
| ).viewClosed; | ||
| if (typeof viewClosed !== "function") { | ||
| return; | ||
| } | ||
|
|
||
| // Handle modal close events so agent workflows can react to cancelled forms. | ||
| viewClosed( |
Contributor
There was a problem hiding this comment.
Unbound method may lose this context
viewClosed is extracted from ctx.app and called as a standalone function on line 374. Unlike ctx.app.action(...) and ctx.app.view(...) earlier in this function, calling viewClosed(...) without binding it to ctx.app may lose the this context. If the Bolt App implementation references this internally (e.g., to register the listener), this would fail at runtime.
Consider calling it as a bound method instead:
Suggested change
| const viewClosed = ( | |
| ctx.app as unknown as { | |
| viewClosed?: ( | |
| matcher: RegExp, | |
| handler: (args: { ack: () => Promise<void>; body: unknown }) => Promise<void>, | |
| ) => void; | |
| } | |
| ).viewClosed; | |
| if (typeof viewClosed !== "function") { | |
| return; | |
| } | |
| // Handle modal close events so agent workflows can react to cancelled forms. | |
| viewClosed( | |
| const viewClosed = ( | |
| ctx.app as unknown as { | |
| viewClosed?: ( | |
| matcher: RegExp, | |
| handler: (args: { ack: () => Promise<void>; body: unknown }) => Promise<void>, | |
| ) => void; | |
| } | |
| ).viewClosed?.bind(ctx.app); | |
| if (typeof viewClosed !== "function") { | |
| return; | |
| } | |
| // Handle modal close events so agent workflows can react to cancelled forms. | |
| viewClosed( |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/slack/monitor/events/interactions.ts
Line: 361:374
Comment:
**Unbound method may lose `this` context**
`viewClosed` is extracted from `ctx.app` and called as a standalone function on line 374. Unlike `ctx.app.action(...)` and `ctx.app.view(...)` earlier in this function, calling `viewClosed(...)` without binding it to `ctx.app` may lose the `this` context. If the Bolt `App` implementation references `this` internally (e.g., to register the listener), this would fail at runtime.
Consider calling it as a bound method instead:
```suggestion
const viewClosed = (
ctx.app as unknown as {
viewClosed?: (
matcher: RegExp,
handler: (args: { ack: () => Promise<void>; body: unknown }) => Promise<void>,
) => void;
}
).viewClosed?.bind(ctx.app);
if (typeof viewClosed !== "function") {
return;
}
// Handle modal close events so agent workflows can react to cancelled forms.
viewClosed(
```
How can I resolve this? If you propose a fix, please make it concise.
This was referenced Feb 16, 2026
Solvely-Colin
force-pushed
the
codex/slack-runtime-blocks-validation
branch
from
February 16, 2026 23:03
e88b0f5 to
eaf2ee6
Compare
Solvely-Colin
force-pushed
the
codex/slack-runtime-blocks-validation
branch
from
February 17, 2026 00:55
eaf2ee6 to
7ef19e5
Compare
Contributor
|
Greptile encountered an error while reviewing this PR. Please reach out to [email protected] for assistance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends Slack Block Kit validation to runtime send/edit paths so all call paths enforce the same payload rules.
validateSlackBlocksArrayhelpersendMessageSlack(..., { blocks })payloadseditSlackMessage(..., { blocks })payloadsScope
src/slack/blocks-input.tssrc/slack/send.tssrc/slack/actions.tssrc/slack/send.blocks.test.tssrc/slack/actions.blocks.test.tsValidation
pnpm test src/slack/send.blocks.test.ts src/slack/actions.blocks.test.tspnpm checkDependency
Depends on:
If reviewing before dependencies merge, review tip commit:
e88b0f53f.