slack-ruby / slack-ruby/slack-ruby-client

After `client.files_upload`, `message.file.size != message.file["size"]`

Open
#294 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

confirmed bug
Dominant language
Ruby
Stars
1.3k
Forks
222
Avg merge
1d 14h
Merged PRs (30d)
3

Description

      message = client.files_upload(
        channels: '\#dev',
        as_user: true,
        file: UploadIO.new('./test.txt', 'text/plain'),
        title: 'test.txt',
        filename: 'test.txt',
        initial_comment: 'testing'
      )
      File.open('./test.txt').size # 27
      message.file.size # 35
      message.file["size"] # 27

message.file.size is then different from message.file["size"]. The latter is both what is shown when printing message.file to the console, and appears to be the actual size of the file. Not sure what the former actually is.

What's going on? Should this be what's going on?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the client.files_upload example with UploadIO and inspect the returned message.file object, comparing its size method with the "size" value. Trace how the upload response is represented and determine whether both access paths should report the same size; done means the discrepancy is explained and the expected behavior is covered by a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.