Skip to content

bucket_id is missing in object/info payload #591

@Vinzent03

Description

@Vinzent03

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The bucket_id, updated_at, lastAccessedAt field of the FileObjectV2 interface is null, although the type definition says it's always a non-null string.

export interface FileObjectV2 {
  id: string
  version: string
  name: string
  bucket_id: string
  updated_at: string
  created_at: string
  last_accessed_at: string
  size?: number
  cache_control?: string
  content_type?: string
  etag?: string
  last_modified?: string
  metadata?: Record<string, any>
}

To Reproduce

When adding a console.log to the get object info test, the bucketId field is missing.

    test('get object info', async () => {
      await storage.from(bucketName).upload(uploadPath, file)
      const res = await storage.from(bucketName).info(uploadPath)
      console.log(res.data) // Added my be

      expect(res.error).toBeNull()
      expect(res.data).toEqual(
        expect.objectContaining({
          id: expect.any(String),
          name: expect.any(String),
          createdAt: expect.any(String),
          cacheControl: expect.any(String),
          size: expect.any(Number),
          etag: expect.any(String),
          lastModified: expect.any(String),
          contentType: expect.any(String),
          metadata: {},
          version: expect.any(String),
        })
      )
    })

I'm wondering why the fields are not checked in the test, though, since the other properties are marked as non null.

> @supabase/[email protected] test:suite
> jest --runInBand

 PASS  test/storageFileApi.test.ts
  ● Console

    console.log
 	{
        id: '3509a8bd-4178-4117-9715-e5bd7ec0510e',
        name: 'testpath/file-1732379139380.jpg',
        version: '3ee7e414-3196-4ab8-b258-9cde399c9ee6',
        size: 29526,
        contentType: 'text/plain;charset=UTF-8',
        cacheControl: 'max-age=3600',
        etag: '"740f5c4bb4f6f2f73c1a301fa455c747"',
        metadata: {},
        createdAt: '2024-11-23T16:25:39.392Z'
    }


      at test/storageFileApi.test.ts:395:15

Expected behavior

The mentioned fields are not null.

System information

  • OS: [Arch Linux]
  • Version of storage-js: [latest main branch state]
  • Version of Node.js: [e.g. v20.15.1]

Additional context

I've noticed this, while trying to implement the info method for the Dart storage package. Dart is strongly typed so marking it as non-null, while being actually null throws an exception.
I've already raised this issue in #541 and got closed, but the change didn't fix this. Even more strange is that the last_modified is missing now, which wasn't the case previously, but that field is not marked as non null.
My pr is still not released, because the correct types are nowhere documented other than in storage-js, which seem to be incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions