slack-samples / deno-simple-survey Goto Github PK
View Code? Open in Web Editor NEWRequest and collect feedback on messages using reacjis
License: MIT License
Request and collect feedback on messages using reacjis
License: MIT License
Or, at least, mention in the README steps, to ignore trigger generation / ctrl+c out of slack run
(which is what I ran when following the instructions) when the CLI suggests to create a trigger if that is what should be done.
If you submit a survey result with no comment, when running locally, you will see this error in your terminal:
2023-03-31 17:46:22 [error] [Wf051B1J9MA7] (Trace=Tr051DRY3HN0) Execution failed for workflow 'Respond to a survey'
parameter_validation_failed - Null value for non-nullable parameter `comments`
If you submit a survey result with a comment, things work as expected.
Easy workaround is to set the Comment field in the survey result submission OpenForm step to required.
In workflows/answer_survey.ts
, there's an attempt to provide a default value for a non-required
output from step 1, response.outputs.fields.comments
:
// Step 2: Append responses to the spreadsheet
AnswerSurveyWorkflow.addStep(SaveResponseFunctionDefinition, {
reactor_access_token_id: AnswerSurveyWorkflow.inputs.reactor_access_token_id,
google_spreadsheet_id: AnswerSurveyWorkflow.inputs.google_spreadsheet_id,
impression: response.outputs.fields.impression,
comments: response.outputs.fields.comments || "",
});
However, response.outputs.fields.comments
isn't a literal string but rather the output to a call to ParamReference
from deno-slack-sdk/src/parameters/param.ts
:
// deno-lint-ignore no-explicit-any
export const ParamReference = (...path: (string | undefined)[]): any => {
const fullPath = path.filter(Boolean).join(".");
return {
toString: () => `{{${fullPath}}}`,
toJSON: () => `{{${fullPath}}}`,
};
};
As a non-empty object, it will never be falsy, so the || ""
is ineffectual, and it is always passed as the value of comments
, even when it doesn't have a value, resulting in runtime errors:
2023-08-04 14:17:56 [info] [Wf05LXTA58F2] (Trace=Tr05L9LC9NSH) Trigger for workflow '%!!(MISSING)s(<nil>)' started:
2023-08-04 14:17:56 [info] [Fn05LXTA55CG] (Trace=Tr05L9LC9NSH) Function 'Respond to a survey' (workflow function) started
2023-08-04 14:17:56 [info] [Wf05LXTA58F2] (Trace=Tr05L9LC9NSH) Workflow 'Respond to a survey' started
2023-08-04 14:17:56 [info] [Wf05LXTA58F2] (Trace=Tr05L9LC9NSH) Workflow step 1 of 2 started
2023-08-04 14:17:56 [info] [Fn010N] (Trace=Tr05L9LC9NSH) Function 'Collect info in a form' (Slack function) started
2023-08-04 14:18:00 [info] [Fn010N] (Trace=Tr05L9LC9NSH) Function 'Collect info in a form' (Slack function) completed
2023-08-04 14:18:01 [info] [Wf05LXTA58F2] (Trace=Tr05L9LC9NSH) Workflow step 'Collect info in a form' completed
2023-08-04 14:18:01 [error] [Wf05LXTA58F2] (Trace=Tr05L9LC9NSH) Workflow step 2 of 2 started
2023-08-04 14:18:01 [error] [Wf05LXTA58F2] (Trace=Tr05L9LC9NSH) Workflow 'Respond to a survey' failed
parameter_validation_failed - Null value for non-nullable parameter `comments`
2023-08-04 14:18:01 [error] [Wf05LXTA58F2] (Trace=Tr05L9LC9NSH) Workflow 'Respond to a survey' failed
parameter_validation_failed - Null value for non-nullable parameter `comments`
2023-08-04 14:18:02 [error] [Fn05LXTA55CG] (Trace=Tr05L9LC9NSH) Function 'Respond to a survey' (%!!(MISSING)s(<nil>) function) failed
parameter_validation_failed - Null value for non-nullable parameter `comments`
I'm still a beginner, so I don't know what the proper way to provide a default value is when piping workflow steps together, but this isn't it.
To ensure stable logic and proper error handling in custom functions, tests should be added with mocks of API endpoints.
These tests should cover the happy path and ensure APIs are called with the correct data the appropriate number of times (for example, conversations.join
should be called for each listed channel in the maintain_membership.ts
function). Error handling should also be tested, particularly for external auth related functionality.
After adding tests, a section on testing should be added to the README.
When running slack manifest validate
, an error is returned. This prevents the app from running locally or being deployed.
โ hermes manifest validate
? Select a workspace filboxworkspace T029V6468RL
? Choose an app environment Local A051PPKF52M
Check /Users/fmaj/.slack/logs/slack-debug-20230410.log for full error logs
๐ซ The provided manifest file does not validate against schema. Consult the additional errors field to locate specific issues (invalid_manifest)
Error Details:
1: Workflow function `create_survey` step `0` param `google_access_token_id` contains an invalid value (invalid_template_values_wf_function_step)
Source: /workflows/create_survey/steps/0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.