google / generative-ai-go

Go SDK for Google Generative AI
Apache License 2.0
486 stars 47 forks source link

invalid memory address or nil pointer dereference while `FileIterator.Next()` #136

Closed meinside closed 4 weeks ago

meinside commented 4 weeks ago

Description of the bug:

(affected by v0.14.0)

Listing uploaded video files with FileIterator.Next() leads to 'invalid memory address or nil pointer deference' error.

Actual vs expected behavior:

Expected: It should iterate through uploaded video files,

Actual: but when calling Next(), it panics with 'invalid memory address or nil pointer deference' error.

Any other information you'd like to share?

https://github.com/google/generative-ai-go/blob/07538e582a63fd3291d1615d2b097221887da95c/genai/files.go#L144-L149

f.Metadata is set to nil here,

so subsequent access to it (f.Metadata.Video) leads to nil pointer dereference.

jba commented 4 weeks ago

Thanks for finding the buggy code!