Skip to content

[JS] Spaces in Media file names and contentType variables does not work #2929

Open
@mattsday

Description

@mattsday

Describe the bug
Using JS and dotprompt files, I have the following:

{{media url=screenshot contentType=contentType}}

If the screenshot variable has a space in it (e.g. gs://MY-BUCKET/test/this and that.png, it return with an error like this:

{"error":{"code":400,"message":"Unable to submit request because it has a mimeType parameter with value and, which is not supported. Update the mimeType and try again. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini","status":"INVALID_ARGUMENT"}}

Where and is the 2nd word of the filename. It works as expected with this prompt, where the contentType is not dynamic:

{{media url=screenshot contentType="image/png"}}

I've tried to URL encode the screenshot URL:

const uploadUrl = `gs://${bucketName}/${encodeURIComponent(input.path).replaceAll("%2F", "/")}`;

This does not work and gives 404 errors:

ClientError: [VertexAI.ClientError]: got status: 404 Not Found. {"error":{"code":404,"message":"No such object: BUCKET_NAME/tasks/xxxxx-test/3m-mega-task/submission/XX%20Product%20list.docx.pdf","status":"NOT_FOUND"}}

Expected behavior
I should be able to dynamically pass the contentType to files with spaces in them. At the moment I'm working around by having several dotPrompt files for each anticipated contentType.

Runtime (please complete the following information):

  • OS: Linux
  • Genkit: 1.9.0

Node version

  • v22.15.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjs

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions