Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error_creating_file_sync when using files.upload #1589

Closed
4 of 10 tasks
secure12 opened this issue Sep 13, 2022 · 6 comments
Closed
4 of 10 tasks

error_creating_file_sync when using files.upload #1589

secure12 opened this issue Sep 13, 2022 · 6 comments
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity server-side-issue

Comments

@secure12
Copy link

secure12 commented Sep 13, 2022

Description

Uploading a post file in response to a slash command fails on random occasions.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 3.12.1

node version: 16.15.0

OS version(s): Ubuntu 20.04.4 LTS (GNU/Linux 5.13.0-1025-aws x86_64)

Steps to reproduce:

  1. The file is read with fs.readFileSync.
  2. A user token is used. (This issue has happened to multiple users. The users have granted the app files.write permission) The file type is post.
  3. Upload the file with the files.upload endpoint
  4. The uploading happens in response to a user using a slash command. There are some API calls to external parties that could take some time before the file is uploaded.

Sample post file file.post:

[] item 1
[] item 2

_Some notes_

Sample script to upload the file:

import {App} from '@slack/bolt';
import {WebClient} from '@slack/web-api';
import fs from 'fs';

const FILE = fs.readFileSync('/some/path/to/file.post');

const upload = async (client: WebClient, channelId: string, token: string) => {
  await client.files.upload({
    channels: channelId,
    file: FILE,
    filename: 'Some post name',
    filetype: 'post',
    token,
  });
};

const getUserToken = (userId: string) => {
 // get user token by user ID
};

const useSlashCommand = (app: App) => {
  app.command('/command', async({ack, client, command}) => {
    await ack();
    const token = getUserToken(command.user_id);
    await upload(client, command.channel_id, token);
  });
};

Expected result:

The file to be always uploaded successfully.

Actual result:

Sometimes (maybe 10% of the time?) the upload function will throw an error like this

{
  "code": "slack_webapi_platform_error",
  "data": {
    "ok": false,
    "error": "error_creating_file_sync",
    "response_metadata": {
      "scopes": ["identify", "chat:write", "files:write"],
      "acceptedScopes": ["files:write"]
    }
  }
}

which is not helpful at all. Also the error code error_creating_file_sync is not listed on the docs describing the endpoint.
This happens seemingly randomly so it's very difficult to debug.

Attachments:

@secure12
Copy link
Author

secure12 commented Sep 13, 2022

The file is not big, by the way. It is just around 2KB. So I don't think it is related to this issue: slackapi/python-slack-sdk#1191

It is also a static file.

@filmaj filmaj added server-side-issue auto-triage-skip Prevent this issue from being closed due to lack of activity labels Sep 13, 2022
@filmaj
Copy link
Contributor

filmaj commented Sep 13, 2022

Hey @secure12, this is unfortunately a known issue with our backend. Apologies for this. Intermittently, file uploads will fail due to security scanning on the backend. This is the same as slackapi/python-slack-sdk#1191, as you identified, but also slackapi/python-slack-sdk#1165.

Do you by any chance have an exact timestamp of when the last failure you saw happened?

@secure12
Copy link
Author

Thanks for your prompt response. It happened once at Sep 13 09:45:23 UTC. It is unintuitive that this is related to security scanning though because sometimes it goes through

@seratch
Copy link
Member

seratch commented Oct 17, 2022

We are going to add a new way to upload files soon. See also: slackapi/node-slack-sdk#1541 (comment)

@zimeg
Copy link
Member

zimeg commented Feb 29, 2024

With files.uploadV2 being public should we close this issue? @seratch

@seratch
Copy link
Member

seratch commented Feb 29, 2024

Yeah, let's do so!

@seratch seratch closed this as completed Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity server-side-issue
Projects
None yet
Development

No branches or pull requests

4 participants