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

upload_file returns 0 byte file with no mime_type (high severity) #628

Closed
mikewadhera opened this issue Nov 11, 2024 · 18 comments
Closed

upload_file returns 0 byte file with no mime_type (high severity) #628

mikewadhera opened this issue Nov 11, 2024 · 18 comments

Comments

@mikewadhera
Copy link

Description of the bug:

genai.upload_file(path=path, mime_type=mime_type)

Any code that was once working downstream of this, including generate_content now fails

Looks like this was from a production push? Started today 11/11/24 around noon PDT.

Also #627 likely related

Actual vs expected behavior:

Expected: a file with proper size_bytes and mime_type

Actual: size_bytes always zero and mime_type always ''

Any other information you'd like to share?

Looks like this was from a production push? Started today 11/11/24 around noon PDT.

Also #627 likely related

@mikewadhera mikewadhera changed the title upload_file returns 0 byte file with no mime_type upload_file returns 0 byte file with no mime_type (high severity) Nov 11, 2024
@sahilshah
Copy link

We are seeing this as well (also Hi Mike!)

@nharada1
Copy link

Same issue here, even manually setting the mime_type doesn't do anything

@sahilshah
Copy link

Even the example notebooks on Gemini docs are broken
e.g. https://ai.google.dev/gemini-api/docs/vision?lang=python

@teyou
Copy link

teyou commented Nov 12, 2024

same here.

@javivallejo
Copy link

Following up for visibility. I reached out on Twitter and got a response, so they should be aware.
https://x.com/OfficialLoganK/status/1856130496058495019

@adboio
Copy link

adboio commented Nov 12, 2024

+1 seeing this as well.

my errors started with a generic 400:

400 Request contains an invalid argument.

after digging around a bit and changing some params, i'm now seeing this for every content gen call that includes a file:

400 Unable to submit request because it has an empty mimeType parameter in fileData. Add a value to the parameter and try again. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini

i'm uploading with an explicit mime-type:

model = genai.GenerativeModel("gemini-1.5-flash")
media_file = genai.upload_file(media_filepath, mime_type=mime_type)

sample file response

genai.File({
'name': 'files/emcdwwnbjjpz',
'display_name': 'video.mp4',
'mime_type': '',
'sha256_hash': '',
'size_bytes': '0',
'state': 'ACTIVE',
'uri': 'https://generativelanguage.googleapis.com/v1beta/files/emcdwwnbjjpz',
'create_time': '2024-11-12T01:12:51.359555Z',
'expiration_time': '2024-11-14T01:12:51.344144581Z',
'update_time': '2024-11-12T01:12:51.359555Z'})

@adboio
Copy link

adboio commented Nov 12, 2024

is this only happening with the python SDK? can we call the API directly as a temp fix here?

@sidpremkumar
Copy link

is this only happening with the python SDK? can we call the API directly as a temp fix here?

failing with the node sdk as well @adboio

@adboio
Copy link

adboio commented Nov 12, 2024

@m-a-sch
Copy link

m-a-sch commented Nov 12, 2024

So happy to not just be the only one. Who changed the server side of file_upload?

@adboio
Copy link

adboio commented Nov 12, 2024

found a potential workaround! 🚀

instead of calling upload_file, use the Blob type and pass file contents directly to the generate_content:

from google.generativeai import protos

model = genai.GenerativeModel("gemini-1.5-pro")

with open(media_filepath, 'rb') as fp:
    file_contents = fp.read()
    media_blob = protos.Blob(data=file_contents, mime_type=mime_type)

    response = model.generate_content([media_blob, prompt_text],
        generation_config=genai.GenerationConfig(
            response_mime_type="application/json", response_schema=Recipe
        )
    )

edit: welp, this only works up to a limit...

400 Request payload size exceeds the limit: 20971520 bytes. The file size is too large. Please use the File API to upload your files instead. Example: `f = genai.upload_file(path); m.generate_content(['tell me about this file:', f])`

@hosopy
Copy link

hosopy commented Nov 12, 2024

I'm having the same issue

@adboio
Copy link

adboio commented Nov 12, 2024

my use-case is for video files, and the workaround i posted above does not work if the files are too large... i tried splitting the file into multiple parts and uploading the blobs individually (like generate_content([ blob1, blob2, blob3, "prompt" ])), but it seems the payload limit is on the entire payload, not individual parts... so i'm not sure of any workaround for larger files at this point

@m-a-sch
Copy link

m-a-sch commented Nov 12, 2024

My work around is to wait. Is this the first major outage of this beautiful product?

@m-a-sch
Copy link

m-a-sch commented Nov 12, 2024

It is fixed. Well done GOOGLE!

@adboio
Copy link

adboio commented Nov 12, 2024

working for me now too!

@davaram
Copy link

davaram commented Nov 12, 2024

It’s finally working again!

But, Why?

@logankilpatrick
Copy link
Member

Hey! We rolled out a fix for this issue, apologies for the delay. I am going to also get a status page setup to make it easier to follow this stuff in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests