Skip to content

[BUG] Various commands are not working in CI context since version 2.33.0. #218

Open

Description

@mroy-seedbox

The deno-slack versions

"deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.15.0/",
"deno-slack-api/": "https://deno.land/x/deno_slack_api@2.8.0/",

Deno runtime version

deno 2.2.2 (stable, release, x86_64-unknown-linux-gnu)
v8 13.4.114.9-rusty
typescript 5.7.3

OS info

We are running on AWS Lambda, specifically in Pipedream.

sw_vers: command not found
uname -v: #1 SMP Wed Jan 22 02:58:04 UTC 2025

Describe the bug

We always get this error, even though the file clearly exists:

This is an invalid Slack app project directory (invalid_app_directory)

Suggestion
   A valid Slack project includes the Slack hooks file: .slack/hooks.json

Steps to reproduce

slack activity -w something -a deployed --skip-update --no-color --token $SLACK_DATABOT_TOKEN

Or slack datastore bulk-put '{"datastore": "something"}' --from-file data.jsonl --app deployed --skip-update --token $SLACK_DATABOT_TOKEN

And probably other commands as well.

Expected result

It works, just as it did in version 2.32.2 and before.

Actual result

It doesn't work ("invalid Slack app"). See above.

Activity

  1. mroy-seedbox commented on Feb 28, 2025

    @mroy-seedbox
    Author

    The issue initially appeared in version 2.33.0.

    Unfortunately, version 3.0.0 did not resolve the issue. 😞

    Related:

  2. mroy-seedbox commented on Feb 28, 2025

    @mroy-seedbox
    Author

    Output from slack doctor:

    SYSTEM
    
        ✔ Operating System (the computer conductor)
            Version: linux (amd64)
    
        ✔ Git (a version control system)
            Version: git version 2.40.1
    
    
    SLACK
    
        ✔ CLI (this tool for building Slack apps)
            Version: v3.0.0
    
        ✔ Configurations (any adjustments to settings)
            System ID: 31ec8d9e-b4c1-4958-9a80-065fcdb2f3f4
            Last updated: 0001-01-01 00:00:00 Z
            Experiments: bolt
    
        ✘ Credentials (your Slack authentication)
          Error: You are either not logged in or your login session has expired (not_authed)
          Suggestion: Authorize your CLI with `slack login`
    
    Errors: 1
    

    No credentials (as expected) since this is a CI context (so using --token instead).

  3. added
    bugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
    on Feb 28, 2025
  4. mwbrooks commented on Feb 28, 2025

    @mwbrooks
    Member

    Hey @mroy-seedbox 👋🏻 I'm deeply sorry that your deployment setup is affected by this bug 😢 But thank you for including so much detail!

    We'll look into reproducing your problem and double-checking the other commands with the --token flag. We'll aim to have a fix available in the next release and I can loop around on this issue when it's available.

    Without the Slack CLI being open sourced, it's been challenging to get the rich feedback that you provided in this issue. While we have unit test coverage and a E2E test pipeline, these issues can still slip through - unfortunately. On the upside, we've got the go-ahead to open source the Slack CLI, so hopefully we can provide more detailed release information and a dedicated issue tracker for feedback.

  5. mroy-seedbox commented on Feb 28, 2025

    @mroy-seedbox
    Author

    Oh, I would've definitely submitted a PR if it were open source!! Can't wait! 😄 🙌 🚀

    And thanks for the response. 🙏

    In the meantime, we're pinned on 2.32.2, so not the end of the world.

  6. zimeg commented on Mar 19, 2025

    @zimeg
    Member

    @mroy-seedbox Thanks for sending this in! 👾 ✨

    In the most recent v3.0.1 we tested and fixed a handful of flag combinations including those with the --token flag for Slack CLI support in a CI context:

    $ curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v 3.0.1

    With the latest update I'm finding that this command no longer errors when run in the project's root directory:

    $ slack activity -w $SLACK_ORG_ID -a deployed --skip-update --no-color --token $SLACK_CLI_TOKEN

    And I'm hoping to call out the root directory here since v2.33.0 - the release after v2.32.2 - made a change to search upwards for a .slack/hooks.json file if a slack command is run, but that might cause problems with certain commands and hook responses 🐟

    The Lambda Pipedream setup you shared is quite interesting to me though also somewhat unfamiliar at the moment. Is it possible to check if the latest changes work alright in your scripts and setup?

    I do hope this issue might be related to flag combinations, but please let me know if the same errors continue! I'm hoping this and following updates continue to find improvements for CI setups, and your comments are so helpful in this! 🙏

  7. mroy-seedbox commented on Mar 19, 2025

    @mroy-seedbox
    Author

    We just tried version 3.0.1, but we're still getting the same error. 😞

    This is an invalid Slack app project directory (invalid_app_directory)
    
    Suggestion
       A valid Slack project includes the Slack hooks file: .slack/hooks.json
    

    However, I cannot reproduce the issue locally. It works when I run the exact same command on my laptop (whether with a token or with slack login). So it must have something to do with the environment. But without seeing the code, I can't be of any more help to debug this issue.

    And we are always running everything from the project root directory.

  8. mroy-seedbox commented on Mar 19, 2025

    @mroy-seedbox
    Author

    @zimeg: Could it be due to the Slack CLI expecting to find a home directory in the environment (i.e. ~/.slack/...)? Because there is no home directory in PIpedream (only a /tmp folder we can use). So right now we're using export SLACK_CONFIG_DIR=/tmp/slack (which is also where the Slack CLI bin is located, just like in our local home directory).

  9. zimeg commented on Mar 19, 2025

    @zimeg
    Member

    @mroy-seedbox Hmm... It's interesting to know this might be an issue in available directories 🔍

    A changed SLACK_CONFIG_DIR environment variable shouldn't cause this error to appear - I cannot find this error with a similar setup on my machine.

    Is it possible to share some of the logs when running this command? I'm wondering if the initial hook parsing is failing or if this might caused within another call:

    $ SLACK_CONFIG_DIR=/tmp/slack slack activity --token $SLACK_CLI_TOKEN --app $SLACK_APP_ID -v
    ...
    [2025-03-19 16:05:13] found authorizations at /tmp/slack/credentials.json reading
    [2025-03-19 16:05:13] starting hook command: deno run -q --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/mod.ts
    [2025-03-19 16:05:13] {"runtime":"deno","hooks":{"get-manifest":"deno run -q --config=deno.jsonc --allow-read --allow-net --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_hooks@1.3.2/get_manifest.ts","get-trigger":"deno run -q --config=deno.jsonc --allow-read --allow-net --allow-env https://deno.land/x/deno_slack_hooks@1.3.2/get_trigger.ts","build":"deno run -q --config=deno.jsonc --allow-read --allow-write --allow-net --allow-run --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_hooks@1.3.2/build.ts","start":"deno run -q --config=deno.jsonc --allow-read --allow-net --allow-run --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_runtime@1.1.2/local-run.ts ","check-update":"deno run -q --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/check_update.ts","install-update":"deno run -q --config=deno.jsonc --allow-run --allow-read --allow-write --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/install_update.ts","doctor":"deno run -q --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/doctor.ts"},"config":{"protocol-version":["message-boundaries"],"watch":{"filter-regex":"\\.(ts|js)$","paths":["."]}}}
    [2025-03-19 16:05:13] finished hook command: deno run -q --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/mod.ts
    [2025-03-19 16:05:13] initialized SDK CLI config: {Runtime:deno Hooks:{BuildProject:{Command:deno run -q --config=deno.jsonc --allow-read --allow-write --allow-net --allow-run --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_hooks@1.3.2/build.ts Name:BuildProject} CheckUpdate:{Command:deno run -q --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/check_update.ts Name:CheckUpdate} Deploy:{Command: Name:Deploy} Doctor:{Command:deno run -q --config=deno.jsonc --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/doctor.ts Name:Doctor} GetHooks:{Command:deno run -q --allow-read --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/mod.ts Name:GetHooks} GetManifest:{Command:deno run -q --config=deno.jsonc --allow-read --allow-net --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_hooks@1.3.2/get_manifest.ts Name:GetManifest} GetTrigger:{Command:deno run -q --config=deno.jsonc --allow-read --allow-net --allow-env https://deno.land/x/deno_slack_hooks@1.3.2/get_trigger.ts Name:GetTrigger} InstallUpdate:{Command:deno run -q --config=deno.jsonc --allow-run --allow-read --allow-write --allow-net https://deno.land/x/deno_slack_hooks@1.3.2/install_update.ts Name:InstallUpdate} Start:{Command:deno run -q --config=deno.jsonc --allow-read --allow-net --allow-run --allow-env --allow-sys=osRelease https://deno.land/x/deno_slack_runtime@1.1.2/local-run.ts  Name:Start}} Config:{Watch:{FilterRegex:\.(ts|js)$ Paths:[.]} SDKManagedConnection:false TriggerPaths:[] SupportedProtocols:[message-boundaries]} WorkingDirectory:}
    [2025-03-19 16:05:13] initialize runtime from hooks.json: Deno (v2.2.3)
    ...
    

    It's also not so clear from the error, but the expected hooks.json file will be in the .slack directory of your project and not the system SLACK_CONFIG_DIR environment variable value. If the above is erroring with something else is it possible to check this too? 👁‍🗨

    Edit: Oh I copied the wrong command altogether...

  10. mroy-seedbox commented on Mar 19, 2025

    @mroy-seedbox
    Author

    Ah, how did I not think about that before! 🤦‍♂

    Here are the logs, which confirm that it is an issue with a missing home directory:

    [2025-03-19 23:49:25] Resolving logstash host, https://slack.com, v3.0.1
    [2025-03-19 23:49:25] system_id: 71711513-bf11-4988-99e1-5b37f6651c06
    [2025-03-19 23:49:25] project_id: afa3c6fb-8c10-4d92-8dff-263ad7aeb330
    [2025-03-19 23:49:25] active flag experiments: []
    [2025-03-19 23:49:25] active project experiments: []
    [2025-03-19 23:49:25] active system experiments: []
    [2025-03-19 23:49:25] active permanently enabled experiments: [bolt]
    [2025-03-19 23:49:25] reading credentials file
    [2025-03-19 23:49:25] found authorizations at /tmp/slack/credentials.json reading
    [2025-03-19 23:49:25] failed to initialize hook configurations: $HOME is not defined
    [2025-03-19 23:49:25] initialize runtime from auto-detect: Deno (v2.2.4)
    [2025-03-19 23:49:25] Starting root command cleanup routine
    Check /tmp/slack/logs/slack-debug-20250319.log for error logs
    This is an invalid Slack app project directory (invalid_app_directory) Suggestion A valid Slack project includes the Slack hooks file: .slack/hooks.json
    [2025-03-19 23:49:25] FlushToLogstash will POST https://slackb.com/events/cli payload: [{"context":{"bin":"...s...l...a...c...k...","cli_version":"3.0.1","command":"datastore bulk-put","command_canonical":"datastore bulk-put","flags":["app","from-file","skip-update","token","verbose"],"host":"e071d093c77461e662dd650e90207769936cc72e","os":"linux","project_id":"afa3c6fb-8c10-4d92-8dff-263ad7aeb330","runtime":"Deno","runtime_version":"v2.2.4","session_id":"6613e9e3-f969-432c-8f59-bbe57c78124e","system_id":"71711513-bf11-4988-99e1-5b37f6651c06"},"data":{"app":{},"auth":{},"error_code":"invalid_app_directory","error_msg":"...T...h...i...s... ...i...s... ...a...n... ...i...n...v...a...l...i...d... ...S...l...a...c...k... ...a...p...p... ...p...r...o...j...e...c...t... ...d...i...r...e...c...t...o...r...y... ...(...i...n...v...a...l...i...d..._...a...p...p..._...d...i...r...e...c...t...o...r...y...)...\n...\n...S...u...g...g...e...s...t...i...o...n...\n... ... ... ...A... ...v...a...l...i...d... ...S...l...a...c...k... ...p...r...o...j...e...c...t... ...i...n...c...l...u...d...e...s... ...t...h...e... ...S...l...a...c...k... ...h...o...o...k...s... ...f...i...l...e...:... .......s...l...a...c...k.../...h...o...o...k...s.......j...s...o...n...\n..."},"event":"error","timestamp":1742428165495}]
    [2025-03-19 23:49:25] FlushToLogstash response status code: 200, body: ok
    

    Specifically this error: failed to initialize hook configurations: $HOME is not defined.

    And yes, our hooks.json is located within the project (not the config dir). 👍

  11. mroy-seedbox commented on Mar 19, 2025

    @mroy-seedbox
    Author

    And when I add export HOME=/tmp, it works! 🎉

    Is that what we should do going forward, or is this something that you will fix on your end?

    Also, surfacing that error message (about the $HOME directory) would have been much more useful than the one about hooks.json not being found! Especially since hooks.json should not be located in the home directory! 😅

  12. mroy-seedbox commented on Mar 20, 2025

    @mroy-seedbox
    Author

    Also, it's weird that it even looks for $HOME (or that it is required at all) when we have already specified SLACK_CONFIG_DIR.

    Why is a home directory even necessary?

  13. zimeg commented on Mar 20, 2025

    @zimeg
    Member

    @mroy-seedbox Wow! I haven't seen this error before, but agree that it should be surfaced to make remediation more clear!

    I'm also not super sure why $HOME is checked if SLACK_CONFIG_DIR is being set... To me this seems like a bug. I'm guessing it might be related to the upward searching .slack/hooks.json though, since we're stopping at $HOME if hooks weren't found. I don't think we've encountered an unset $HOME variable before 😅

    Thinking aloud, I'm not certain how an unset $HOME or project not within the $HOME directories might behave with upwards searches?

    It might be easiest to not search upwards in these cases, but perhaps a SLACK_PROJECT_DIR variable could later allow this? I'd be interested to know your thoughts!

    📝 To note, I'm hoping we can fix errors from an unset $HOME on the CLI side of things, but for now the workaround you're sharing is a solid patch! We'll share more updates on this soon too, but also let me know of other ideas-

  14. mroy-seedbox commented on Mar 20, 2025

    @mroy-seedbox
    Author

    Well, I see two distinct issues here:

    1. .slack/hooks.json should exist within the project that is being executed, so we shouldn't need to search any higher than the project root.
      • And as you suggested, a SLACK_PROJECT_DIR might make this more explicit.
      • But we should also be able to identify the root by locating the .slack folder, especially if it is in the current directory (no searching required). So not searching upward would support this.
      • And if a $HOME directory is not found, maybe just default to / as the home/root for those environment?
    2. SLACK_CONFIG_DIR is a completely separate concern. And when it is specified, it should override directory searching (if any).
      • Although in theory, SLACK_CONFIG_DIR and the project itself can/should be in two completely different places, so I'm not sure why any directory searching would be required for this. 🤔
      • So ignore my previous message (now that I understand the issue better): "Also, it's weird that it even looks for $HOME (or that it is required at all) when we have already specified SLACK_CONFIG_DIR."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions