Responses from `filesUploadV2` have files nested in the `files` array
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- nodejs, typescript
- 領域
- api
調査の方向性
packages/web-api/src/WebClient.ts の 454 行目付近から始めて、filesUploadV2 が完了レスポンスをどのように組み立てているかを調べます。現在の形を issue にある単一ファイルおよび複数ファイルの例と比較し、返されるファイル ID に期待されるインデックスでアクセスできることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 3.4k
- フォーク
- 693
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 67
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
slackapi/node-slack-sdk のほかの issue
-
auto-triage-skip enhancement pkg:web-api
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
slackapi/node-slack-sdk#2607 · コメント 2 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
`SlackListsItem FieldMessage.message` type does not match API response shape対応中かも @AjTheSpidey が 202 日前に担当しました。 オープンarea:typescript auto-triage-skip bug pkg:web-api
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
slackapi/node-slack-sdk#2598 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Missing TypeScript response type for files.uploadV2対応中かも @Yshuro が 6 日前に担当しました。 オープンarea:typescript auto-triage-skip bug pkg:web-api
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
slackapi/node-slack-sdk#2459 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Docs/types: document `broadcast_delete` on chat.delete (undo reply_broadcast)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea:typescript enhancement pkg:web-api semver:patch
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
slackapi/node-slack-sdk#2815 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
auto-triage-stale
難易度 3/5 1〜2日 初心者へのやさしさ 75/100
slackapi/node-slack-sdk#2791 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
slackapi/node-slack-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
agilepathway/label-checker#1015 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
bug P3
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
react-component/image#541 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信