Skip to content

[BUG] Open Form does not support uploading a file #468

@nikcheerla

Description

@nikcheerla

The deno-slack versions

"deno-slack-sdk/": "https://deno.land/x/[email protected]/",
"deno-slack-api/": "https://deno.land/x/[email protected]/"

Deno runtime version

deno --version
deno 2.3.7 (stable, release, aarch64-apple-darwin)
v8 13.7.152.6-rusty
typescript 5.8.3

OS info

sw_vers && uname -v
ProductName: macOS
ProductVersion: 14.5
BuildVersion: 23F79
Darwin Kernel Version 23.5.0: Wed May 1 20:13:18 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6030

Describe the bug
Not 100% sure that this is a bug or just an unsupported/unimplemented feature, but the documentation is misleading. The documentation on 'Creating a Form' implies that when you create an OpenForm you can add an option to upload a file. Unfortunately this doesn't seem to work and there are validation errors.

Steps to reproduce

  1. Create a manifest.ts with appropriate scopes (including files:read)
  2. Create a workflow
  3. Add a form to the workflow with a file_id parameter

Manifest.ts

import { Manifest } from "deno-slack-sdk/mod.ts";
import ReportBugWorkflow from "./workflows/report_bug_workflow.ts";

/**
 * The app manifest contains the app's configuration. This
 * file defines attributes like app name and description.
 * https://api.slack.com/automation/manifest
 */
export default Manifest({
  name: "Bug Report",
  description:
    "Report bugs to Slack and link Linear issues + create incidents automatically",
  icon: "assets/app-icon.png",
  workflows: [ReportBugWorkflow],
  botScopes: [
    "commands",
    "chat:write",
    "chat:write.public",
    "files:read",
  ],
});

report-bug-workflow.ts

import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts";
import { ReportBugFunctionDefinition } from "../functions/report_bug_function.ts";
import {
  getProductAreaChoices,
  getProductAreaEnum,
} from "../functions/product_area_mapping.ts";

/**
 * A workflow is a set of steps that are executed in order.
 * Each step in a workflow is a function.
 * https://api.slack.com/automation/workflows
 */
const ReportBugWorkflow = DefineWorkflow({
  callback_id: "report_bug_workflow",
  title: "Report a bug",
  description: "Report a bug to the development team",
  input_parameters: {
    properties: {
      interactivity: {
        type: Schema.slack.types.interactivity,
      },
      channel: {
        type: Schema.slack.types.channel_id,
      },
    },
    required: ["interactivity"],
  },
});

/**
 * For collecting input from users, we recommend the
 * built-in OpenForm function as a first step.
 * https://api.slack.com/automation/functions#open-a-form
 */
const inputForm = ReportBugWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Report a bug",
    interactivity: ReportBugWorkflow.inputs.interactivity,
    submit_label: "Report bug",
    fields: {
      elements: [{
        name: "what_happened",
        title: "What happened?",
        description:
          "Be specific. What did you expect to occur and what actually happened? Share any screenshots for added context in the thread after.",
        type: Schema.types.string,
        long: true,
      }, {
        name: "file_upload",
        title: "Upload additional screenshots or files",
        description: "Upload additional screenshots or files",
        type: Schema.slack.types.file_id,
      }],
      required: [
        "what_happened",
      ],
    },
  },
);

Expected result

Creates a form without issues

Actual result

Image

Requirements

You should be able to upload a file with open-form

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions