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

getFile method gives 403 Forbidden Error even with permission on service account #236

Open
navarrodiego opened this issue Aug 22, 2024 · 2 comments

Comments

@navarrodiego
Copy link

navarrodiego commented Aug 22, 2024

Description of the bug:

When I execute this (simplified) code in a container running in Google Cloud Run Job:

import crypto from 'crypto';
import { GoogleAIFileManager } from "@google/generative-ai/server";

const geminiApiKey = process.env.GEMINI_API_KEY as string;
const fileManager = new GoogleAIFileManager(geminiApiKey);

// If the URL is repeated, the fileHash will be the same
const url = "https://exampleUrl.com"
const fileHash = crypto.createHash('md5').update(url).digest('hex');

// Check if the image is already uploaded
try {
  const existingFile = await fileManager.getFile(fileHash);
} catch (error) {
  console.error(error)
}

I get this error:

[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/files/<<myUri>>: [403 Forbidden] You do not have permission to access the File <<myUri>> or it may not exist.

My Cloud Run Job is running using a Service Account that has the role "aiplatform.admin".

Actual vs expected behavior:

Actual behavior: I get an error.
Expected behavior: Get the image file object when i call the getFile method.

Any other information you'd like to share?

No response

@navarrodiego navarrodiego changed the title fileManager.getFile gives 403 Forbidden Error even with permission on service account getFile method gives 403 Forbidden Error even with permission on service account Aug 23, 2024
@saxzzy94
Copy link

saxzzy94 commented Sep 5, 2024

getting the same error on the getFile Method

@ashuChoudhuryDeveloper
Copy link

Same here

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

3 participants