Skip to content

[firebase_vertexai]: FormatException: Unhandled ContentModality format DOCUMENT #17185

@leifarne

Description

@leifarne

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Storage

Which platforms are affected?

Web

Description

The following code generates the above error:

import 'package:firebase_vertexai/firebase_vertexai.dart';

final _model = FirebaseVertexAI.instance.generativeModel(model: 'gemini-2.0-flash');

final content = Content.multi([
TextPart('Hva er minste lovlige oppsigelsestid i arbeidsforhold?'),
FileData('application/pdf', 'gs://tenor-y.appspot.com/arbeidsliv/arbeidsmiljoloven.pdf'),
]);
final response = await _model.generateContent([content]);

Plugin version:
firebase_vertexai: ^1.4.0

So it means that Vertex AI cannot read PDFs from Firebase Storage. There is a similar issue thread, but with other file types. If I replace the pdf with a plain txt file, everything works. So the problem is related to PDFs.

Comments are appreciated.

Reproducing the issue

import 'package:firebase_vertexai/firebase_vertexai.dart';

final _model = FirebaseVertexAI.instance.generativeModel(model: 'gemini-2.0-flash');

final content = Content.multi([
TextPart('Hva er minste lovlige oppsigelsestid i arbeidsforhold?'),
FileData('application/pdf', 'gs://tenor-y.appspot.com/arbeidsliv/arbeidsmiljoloven.pdf'),
]);
final response = await _model.generateContent([content]);

Firebase Core version

3.12.1

Flutter Version

3.6.0

Relevant Log Output

DartError: FormatException: Unhandled ContentModality format
DOCUMENT

Flutter dependencies

Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionThis issue needs maintainer attention.platform: webIssues / PRs which are specifically for web.plugin: vertexailabel issues for vertexai pluginresolution: fixedA fix has been merged or is pending merge from a PR.type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions