-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to ack with errors #252
Comments
I wasn't able to reproduce this. The error seems kind of weird because it reads like it's not recognizing the dialog as a Here's the code I have that seems to be working for me, but the
|
@shanedewael maybe y’all fixed it with a recent update? I can try again later and see if I’m still getting the same error. |
Hmm maybe something was touched when we were implementing support for Block Kit in modals but I didn't think that code had been touched for a while. If you try again later and are able to reproduce, let me know and I can dig into it further. |
@shanedewael Just retested after running
|
That's odd to me. Do you mind sharing the Bolt code you're using to |
As pointed out here, the code in the document seems to be not working with TypeScript (to be precise, TS transpiration fails). I haven't checked the behavior with all the past versions, but at least it doesn't successfully transpire with either 1.0.0 or 1.3.0. A workaround to address this issue would be to explicitly determine the import { App, DialogSubmitAction } from '@slack/bolt';
// <DialogSubmitAction> here is necessary at this point
app.action<DialogSubmitAction>({callback_id: 'CALLBACK_ID'}, ({ ack }) => {
ack({
errors: [{
"name": "email_address",
"error": "Sorry, this isn’t a valid email"
}]
});
}); |
@shanedewael
import { App, LogLevel } from '@slack/bolt';
// Workaround until this issue is closed: https://github.com/slackapi/bolt/issues/250
// TODO: Uninstall @slack/web-api dependency when this is fixed
import { WebClient } from '@slack/web-api';
import commands from './Commands';
if (!process.env.SLACK_SIGNING_SECRET || !process.env.SLACK_BOT_TOKEN) {
throw new Error('SLACK_SIGNING_SECRET and SLACK_BOT_TOKEN are required environment variables');
}
const app = new App({
signingSecret: process.env.SLACK_SIGNING_SECRET,
token: process.env.SLACK_BOT_TOKEN,
logLevel: process.env.NODE_ENV === 'development' ? LogLevel.DEBUG : LogLevel.INFO,
});
// Initialize the WebClient for future use
app.client = new WebClient(process.env.SLACK_BOT_TOKEN);
// Register routes
commands(app);
export default app;
import { App } from '@slack/bolt';
import someCommand from './someCommand';
import logger from '../logger';
export default function register(app: App): void {
logger.info('Registering slash command listeners');
someCommand(app);
}
import { callbackId, dialog } from '../Blocks/sevDialogBlocks';
import { App, DialogSubmitAction } from '@slack/bolt';
export default function register(app: App): void {
app.command(slashCommand, async ({
command, ack, context, respond,
}) => {
// Acknowledge the request so Slack doesn't get angry
ack();
await app.client.dialog.open({
token: context.botToken,
trigger_id: command.trigger_id,
dialog,
});
});
app.action({ callback_id: callbackId }, async ({ ack, action, body }) => {
ack({
errors: [{
name: 'loc_origin',
error: 'ugh please work',
}]
});
}); |
I'm able to reproduce this one now as well. I think @seratch's use of Generics is the best solution for this right now as well. |
Just updated the description of the issue with the workaround provided by @seratch in case others find this and have the same problem. |
Thanks for doing that, I'm going to close this issue out for now. |
Well is that intended behavior? I feel like without an update to the docs, this shouldn’t be closed. |
@SpencerKaiser Hmmm that's a fair point. I'm not sure where this would go into the documentation since we're primarily highlighting |
I was today years old when I found out that modals exist....... But that’s totally fair, as long as the docs have some info to help those using the (apparently) old school stuff, I’m happy. |
Modals were just released released last week so you aren't too behind 😜 |
Description
The example for how to respond to a dialog with errors will not compile in typescript.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
When trying to respond to a dialog submission with validation errors, the
ack
method will not accept an object with error values.Steps to reproduce:
ack
:Expected result:
ack
should accept an errors response objectActual result:
Compilation error.
Workaround
Credit to @seratch!
The text was updated successfully, but these errors were encountered: