Closed mcsescott closed 5 months ago
Hi @mcsescott is this this behavior still happening?
Thanks for the follow-up. Yes, it is. I just tried a different app and the issue still occurs. It installs fine with slack run
but fails with slack deploy
⠴ Packaging app for deploymentX [ERROR] Could not resolve "\\Users\\spatton\\Downloads\\Slack Workflows\\Applications\\NextGen Apps\\MPDM to Channel\\functions\\mpdm_to_private_function.ts" [plugin deno-resolver]
The plugin "deno-resolver" didn't set a resolve directory, so esbuild did not search for "\\Users\\spatton\\Downloads\\Slack Workflows\\Applications\\NextGen Apps\\MPDM to Channel\\functions\\mpdm_to_private_function.ts" on the file system.
Error bundling function file "mpdm2private_function" with esbuild
error: Uncaught (in promise) Error: Build failed with 1 error:
error: Could not resolve "\\Users\\spatton\\Downloads\\Slack Workflows\\Applications\\NextGen Apps\\MPDM to Channel\\functions\\mpdm_to_private_function.ts"
let error = new Error(text);
^
at failureErrorWithLog (https://deno.land/x/esbuild@v0.19.4/mod.js:1626:15)
at https://deno.land/x/esbuild@v0.19.4/mod.js:1035:25
at runOnEndCallbacks (https://deno.land/x/esbuild@v0.19.4/mod.js:1461:45)
at buildResponseToResult (https://deno.land/x/esbuild@v0.19.4/mod.js:1033:7)
at https://deno.land/x/esbuild@v0.19.4/mod.js:1062:16
at responseCallbacks.<computed> (https://deno.land/x/esbuild@v0.19.4/mod.js:679:9)
at handleIncomingPacket (https://deno.land/x/esbuild@v0.19.4/mod.js:739:9)
at readFromStdout (https://deno.land/x/esbuild@v0.19.4/mod.js:655:7)
at https://deno.land/x/esbuild@v0.19.4/mod.js:1924:11
at eventLoopTick (ext:core/01_core.js:65:7)
⠹ Packaging app for deploymentCheck C:\Users\spatton\.slack\logs\slack-debug-20240221.log for full error logs
This seems to be related to how the functions are being bundled before they are sent to the Slack, here is the relevant snippet
Important to note that before bundling with esbuild
we try to bundle with the the default deno bundler this seems to fail as well
This may be due to the path of your project their seems to be some folders that contain spaces, I've been bit by this in the past could you try renaming your folders something like \Downloads\Slack_Workflows\Applications\NextGen_Apps\MPDM_to_Channel\functions\mpdm_to_private_function.ts
Also if it is possible could you share the contents of mpdm_to_private_function.ts?
I am also working with a couple of TAs (who might reach out to you internally), and today we tried a couple of things:
As far as sharing the functions, I would rather not do that on a public forum. I will see if I can pare it down to just the bare bones function definition with simple code to see if it will work.
Update: I updated the Slack CLI (as well as the deno hooks and api via slack update
) and the error message is a little different:
⠴ Packaging app for deploymenterror: Uncaught (in promise) Error: Could not find file: C:\Users\spatton\Downloads\Slack\functions\mpdm_to_private_function.ts. Make sure the function
definition with ID mpdm2private_function's source_file is relative to your project root.
throw new Error(
^
at validateManifestFunctions (https://deno.land/x/deno_slack_hooks@1.2.3/utilities.ts:68:15)
at eventLoopTick (ext:core/01_core.js:65:7)
at async validateAndCreateFunctions (https://deno.land/x/deno_slack_hooks@1.2.3/build.ts:25:3)
at async https://deno.land/x/deno_slack_hooks@1.2.3/build.ts:144:3
Packaging app for deployment
Check C:\Users\spatton\.slack\logs\slack-debug-20240223.log for full error logs
> error packaging project: Command for 'BuildProject' returned an error: exit status 1 (sdk_hook_invocation_failed)
Suggestion:
Run `slack doctor` to check that your system dependencies are up-to-date.
PS C:\Users\spatton\Downloads\Slack Workflows\Applications\nextgen apps\mpdm to channel> slack doctor
SYSTEM
✔ Operating System (program scheduler and such)
Version: windows (amd64)
✔ Deno (a JavaScript runtime)
Version: v1.40.4
Recommendation: We suggest using the latest version of Deno
✔ Git (a version control system)
Version: git version 2.43.0.windows.1
SLACK
✔ CLI (this tool for building Slack apps)
Version: 2.18.0
✔ Configurations (any adjustments to settings)
System ID: e291ea02-05f3-435c-a2ff-961fc5707a8e
Last updated: 2024-02-23 10:59:00 -06:00
Experiments: None
✔ Credentials (your Slack authentication)
Team domain: verizon-sandbox
Team ID: E010X9P37H6
User ID: U01H9AJPCUF
Last updated: 2024-02-23 09:23:55 -06:00
Authorization level: Organization
Token status: Valid
PROJECT
✔ Configurations (your project's CLI settings)
Project ID: 1c28dc06-3a3e-40cc-aa32-ce0d3e004ca6
✔ Dependencies (requisites for development)
deno_slack_hooks: 1.2.3
deno_slack_sdk: 2.6.0
deno_slack_api: 2.2.0
Errors: 0
Just to do be rigorous does this file path C:\Users\<your_user>\Downloads\Slack\functions\mpdm_to_private_function.ts
exist on your machine?
And is the value of the source_file
field in the function definition relative to the root of your project?
Example
export const PostIssueMessage = DefineFunction({
callback_id: "post_issue_message",
title: "Post an issue to channel",
description: "Create an issue message from submitted form",
source_file: "functions/post_issue_message.ts", // not C:\Users\<your_user>\path\to\project\functions\post_issue_message.ts
input_parameters: {
properties: {
channel: {
type: Schema.slack.types.channel_id,
}
},
required: ["channel"],
},
output_parameters: {
properties: {
channel: {
type: Schema.slack.types.channel_id,
},
},
required: [],
},
});
Yes, and yes (and yes). Again, the app will run if it run locally slack run
it is just when I try to deploy it is when I get the errors.
I have tried directories with spaces and without. I even get the error on the simple Hello World app tutorial (without any modifications to the code).
Could you try running the following steps and sharing the results, these work on my end
slack create test-hello-world -t https://github.com/slack-samples/deno-hello-world
cd test-hello-world/
slack deploy
+ create the triggerWorking with my TA, we have discovered the issue, and it appears to be a Deno linting issue with VSCode. It basically comes down to Deno being very type strict, unlike Javascript.
We adjusted the code (and added checks/assertions for null values), and I have been able to deploy it now. Thanks for your assistance.
It basically comes down to Deno being very type strict, unlike Javascript.
I was facing the same problem/error as @mcsescott and the sentence above gave me the idea to comment out some code that calls the GitHub API in a custom function...I was then able to deploy just fine :+1:
@WilliamBergamin the error message being returned by the Slack CLI in this case is quite perplexing. It seems that the underlying cause is "linting" failures. For example, in my case my function file has this import:
import { Octokit } from "https://esm.sh/octokit@4.0.2?dts";
In VS Code, deno-lint
will show me this error (note the deno-lint(no-unused-vars)
text):
The linter is telling me I haven't used the Octokit
reference that I imported. When this is the case slack deploy
will fail with the error messages @mcsescott was posting.
👉 If I comment out the unused import then the linting error disappears and slack deploy
works just fine 👈
I don't know the underlying mechanics, but if slack deploy
is able to report errors directly from the underlying build tool, it may help make scenarios like this easier to troubleshoot on the CLI 👍
I am getting the same error as closed issue as #258.
I am using Windows, and the local app installs and runs just fine. When I try to deploy it via
slack deploy
I get the following error:Note: certain values XXXX out due to this being a public forum.
I see no errors in my code, so not sure if the resolution mentioned above would apply. If there was an error, then why would it work when running locally?