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

bucket_id is missing in object/info payload #591

Open
2 tasks done
Vinzent03 opened this issue Nov 23, 2024 · 0 comments
Open
2 tasks done

bucket_id is missing in object/info payload #591

Vinzent03 opened this issue Nov 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Vinzent03
Copy link

Vinzent03 commented Nov 23, 2024

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.

@Vinzent03 Vinzent03 added the bug Something isn't working label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant