Responses from `filesUploadV2` have files nested in the `files` array
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- nodejs, typescript
- Domain
- api
Research direction
Start in packages/web-api/src/WebClient.ts around line 454 and inspect how filesUploadV2 assembles its completion response. Compare the current shape with the single-file and multi-file examples in the issue, then verify that the returned file IDs are accessible at the expected indexes.
Written by the indexing model from the issue text.
Description
Overview
A successful response from uploading files with the filesUploadV2 API contains a files attribute after a request like so:
const result = await web.filesUploadV2({
token: "xoxp-example",
channel_id: "C0123456789",
file: "hello",
filename: "greetings.md",
});
{
ok: true,
files: [ { ok: true, files: [Array], response_metadata: [Object] } ]
}
Which means accessing the ID of this file needs:
console.log(result.files[0].files[0].id);
The first [0] index is also consistent when multiple files are uploaded:
const result = await web.filesUploadV2({
token: "xoxp-example",
channel_id: "C0123456789",
file_uploads: [
{
file: "README.md",
filename: "README.md",
},
{
content: "hello",
filename: "greetings.md",
},
],
});
console.log(result.files[0].files[0].id); // F00000README
console.log(result.files[0].files[1].id); // F00GREETINGS
Expected behaviors
This seems like unexpected behavior so wanted to check - it caught me by surprise! I expected result.files[0].id and result.files[1].id to have the file IDs 🤔
I found the following quick change removes the middle files[0] too:
- return { ok: true, files: completion };
+ return {
+ ok: true,
+ files: completion[0].files as FilesGetUploadURLExternalResponse[],
+ response_metadata: completion[0].response_metadata,
+ };
Also noticing a few oddities around typing differences between filesUploadV2 and files.uploadV2 but this doesn't seem so important to me if filesUploadV2 is the recommended method of file uploads (typings work well here!).
Packages:
Select all that apply:
-
@slack/web-api
Reproducible in:
The Slack SDK version
@slack/[email protected]
@slack/[email protected]
Node.js runtime version
v20.12.2
OS info
ProductName: macOS
ProductVersion: 14.5
BuildVersion: 23F79
Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
Requirements
For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
- Dominant language
- TypeScript
- Stars
- 3.4k
- Forks
- 693
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 67
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from slackapi/node-slack-sdk
-
auto-triage-skip enhancement pkg:web-api
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
slackapi/node-slack-sdk#2607 · 2 comments · 2 reactions ·
Maintainers usually reply within 1 day
-
`SlackListsItem FieldMessage.message` type does not match API response shapePossibly taken @AjTheSpidey claimed this 202 days ago. Openarea:typescript auto-triage-skip bug pkg:web-api
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
slackapi/node-slack-sdk#2598 · 2 comments ·
Maintainers usually reply within 1 day
-
Missing TypeScript response type for files.uploadV2Possibly taken @Yshuro claimed this 6 days ago. Openarea:typescript auto-triage-skip bug pkg:web-api
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
slackapi/node-slack-sdk#2459 · 2 comments ·
Maintainers usually reply within 1 day
-
Docs/types: document `broadcast_delete` on chat.delete (undo reply_broadcast)Possibly taken A pull request linked to this issue is open or already merged. Openarea:typescript enhancement pkg:web-api semver:patch
Difficulty 5/5 Over a week Newbie friendliness 25/100
slackapi/node-slack-sdk#2815 · 1 comment ·
Maintainers usually reply within 1 day
-
auto-triage-stale
Difficulty 3/5 1-2 days Newbie friendliness 75/100
slackapi/node-slack-sdk#2791 · 1 comment ·
Maintainers usually reply within 1 day
All issues in slackapi/node-slack-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
agilepathway/label-checker#1015 · 2 comments ·
Maintainers usually reply within 1 day
-
tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug P3
Difficulty 1/5 Under an hour Newbie friendliness 89/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
react-component/image#541 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day