slackapi / deno-slack-sdk

SDK for building Run on Slack apps using Deno
https://api.slack.com/automation
MIT License
162 stars 27 forks source link

[BUG] receiving function_not_deployed on Enterprise Grid #300

Closed FallingReign closed 5 months ago

FallingReign commented 6 months ago

The deno-slack versions

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

Deno runtime version

OS info

Describe the bug

App is deployed to Enterprise Grid and function has been installed however I receive the following errors in the log.

2024-04-06 16:49:29 [info] [Fn06KT151MGQ] (Trace=Tr06SP39FE79) Function 'Create issue using Jira API' (app function) started
2024-04-06 16:49:29 [error] [Fn06KT151MGQ] (Trace=Tr06SP39FE79) Function output:
        function_not_deployed
2024-04-06 16:49:29 [error] [Fn06KT151MGQ] (Trace=Tr06SP39FE79) Function 'Create issue using Jira API' (app function) failed
        event_dispatch_failed
2024-04-06 16:49:30 [error] [Wf06KP1F2Z9D] (Trace=Tr06SP39FE79) Workflow step 'Create issue using Jira API' failed

Steps to reproduce

No useful steps to report other than Deploy to Enterprise and notice it fails to execute the function within the workflow. Workflow was create using the slack gui and not in source. Source is just making API calls to Jira.

This all works when running locally in a sandbox.

Not sure it is related but when trying to redeploy the app to the grid I get the following error: team_access_not_granted

Expected result

workflow function to complete successfully.

@User ran a workflow that you built and there was a problem with the Create issue using Jira API step: Function failed to execute You can view the details for this error in the activity logs

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

WilliamBergamin commented 6 months ago

Hi @FallingReign thanks for writing in 💯

Would you be able to share the output of the slack manifest command?

FallingReign commented 5 months ago

Hey @WilliamBergamin,

Something I remembered is that I have added custom environment variables as follows (fake examples).

output of slack manifest is as follows:

{
  "_metadata": {
    "major_version": 2
  },
  "display_information": {
    "name": "Slack Tools",
    "description": "Tools for Slack Workflows"
  },
  "features": {
    "app_home": {
      "messages_tab_enabled": true,
      "messages_tab_read_only_enabled": true
    },
    "bot_user": {
      "display_name": "Slack Tools"
    }
  },
  "oauth_config": {
    "scopes": {
      "bot": [
        "commands",
        "chat:write",
        "chat:write.public"
      ]
    },
    "token_management_enabled": false
  },
  "settings": {
    "org_deploy_enabled": true,
    "incoming_webhooks": {},
    "function_runtime": "slack",
    "siws_links": {}
  },
  "functions": {
    "jira_create_issue": {
      "title": "Create issue using Jira API",
      "description": "",
      "input_parameters": {
        "properties": {
          "project": {
            "type": "string",
            "title": "Project Key",
            "description": "eg. JUP"
          },
          "issue_type": {
            "type": "string",
            "title": "Issue Type",
            "enum": [
              "10000",
              "10001",
              "10100"
            ],
            "choices": [
              {
                "value": "10200",
                "title": "Task"
              },
              {
                "value": "10203",
                "title": "Bug"
              },
              {
                "value": "10000",
                "title": "Epic"
              }
            ]
          },
          "summary": {
            "type": "string",
            "title": "Summary"
          },
          "description": {
            "type": "string",
            "title": "Description",
            "long": true
          },
          "mode_location": {
            "type": "string",
            "title": "Mode/Location",
            "enum": [
              "Global",
              "MP",
              "SP"
            ],
            "choices": [
              {
                "value": "Global",
                "title": "Global -\u003e MODE"
              },
              {
                "value": "MP",
                "title": "MP -\u003e MODE"
              },
              {
                "value": "SP",
                "title": "SP-\u003e MODE"
              }
            ]
          },
          "level": {
            "type": "string",
            "title": "Level",
            "description": "map name"
          },
          "reporter": {
            "type": "string",
            "title": "Reporter"
          }
        },
        "required": [
          "project",
          "issue_type",
          "summary"
        ]
      },
      "output_parameters": {
        "properties": {
          "key": {
            "type": "string",
            "description": "Key"
          },
          "link": {
            "type": "string",
            "description": "Issue Link"
          }
        },
        "required": []
      }
    }
  },
  "outgoing_domains": [
    "dev.examplecompany.com"
  ]
}
WilliamBergamin commented 5 months ago

Thank you 💯 this manifest seems valid Are you using the same account to create/deploy the app and builder the workflow in workflow builder? (this could potentially be related to custom function distribution )

What happens it you try to run deno run -q --config=deno.jsonc --allow-read --allow-write --allow-net --allow-run --allow-env https://deno.land/x/deno_slack_hooks@1.3.0/build.ts? this should bundle you functions and place them in a ./dist directory in your project

WilliamBergamin commented 5 months ago

Hi @FallingReign your issue might have been related to another internal issue that was fixed yesterday, would you mind waiting for the next version of the CLI to be released and then seeing if your issues are still present

FallingReign commented 5 months ago

@WilliamBergamin I don't mind waiting a bit if needed. In the meantime I ran the deno command you mentioned above and it did completed successfully.

WilliamBergamin commented 5 months ago

@FallingReign since the command completed successfully, I assume your projects gets bundled and uploaded properly The next release of the CLI should be out on April 18th, let us know if it fixed your issue

WilliamBergamin commented 5 months ago

@FallingReign let us know if the latest version of the CLI resolves this issue

slack upgrade should bring the tool up to date 💯

FallingReign commented 5 months ago

@WilliamBergamin - I have been successful in deploying the function following the upgrade. However, it appears that I am now hitting the timeout and getting the following

2024-04-24 15:28:58 [info] [Fn06KT151MGQ] (Trace=Tr0709CN6N85) Function 'Create issue using Jira API' (app function) started
2024-04-24 15:31:01 [info] [Fn06KT151MGQ] (Trace=Tr0709CN6N85) Function output:
        error: function execution exceeded 60.0s timeout
2024-04-24 15:31:02 [error] [Fn06KT151MGQ] (Trace=Tr0709CN6N85) Function 'Create issue using Jira API' (app function) failed
        event_dispatch_failed
2024-04-24 15:31:02 [error] [Wf06KP1F2Z9D] (Trace=Tr0709CN6N85) Workflow step 'Create issue using Jira API' failed

This is interesting as it works locally without issue.

My initial thought was that it could potentially be the difference between being run locally and being deployed based on our Jira environment not being externally visible. I will need to do some more investigating. If this is the case, then perhaps this app must be deployed internally.

WilliamBergamin commented 5 months ago

This is great news 💯 it seems like we resolved the deployment issue

As for the execution exceeded 60.0s timeout this is most likely caused by your Jira environment not being externally visible, Slacks hosting infrastructure is unable to reach private networks/services