Skip to content

Conversation

@atticoos
Copy link

@atticoos atticoos commented Dec 18, 2025

Problem

Blob uploads are missing document names. As a result, when querying the FileSearchStore via the Gemini tool, GroundingMetadata doesn't include the document name, since it doesn't exist -- which means citations can't back reference the document they originated from.

Reason

uploadFileToFileSearchStore accepts a displayName per UploadToFileSearchStoreConfig

js-genai/src/types.ts

Lines 4989 to 4990 in 8683694

/** Display name of the created document. */
displayName?: string;

However, it is ignored, and instead the file name is determined by getFileName(file), basing the name off of the file path

js-genai/src/_api_client.ts

Lines 673 to 680 in 8683694

private getFileName(file: string | Blob): string {
let fileName: string = '';
if (typeof file === 'string') {
fileName = file.replace(/[/\\]+$/, '');
fileName = fileName.split(/[/\\]/).pop() ?? '';
}
return fileName;
}

Furthermore, when providing a Blob as the file, there is no file path, so the document is left unnamed, even if displayName is provided.

Solution

When config.displayName is provided, use that. Otherwise, fallback to existing behavior via getFileName(name)

Reproducible Steps

  1. Add a file from a Blob to a FileSearchStore
client.fileSearchStores.uploadToFileSearchStore({
  fileSearchStoreName: 'fileSearchStores/X',
  file: new Blob(['I will not have a displayName'], { mimeType: 'text/plain' }),
  config: {
    displayName: 'This name will not appear',
    mimeType: 'text/plain'
  }
});
  1. Query the document, it will come back without a displayName
{
  "documents": [
    {
        "name": "fileSearchStores/teststore-h96irg23frs2/documents/testfiletxt-kjvz41r4ubzb",
        "updateTime": "2025-12-18T21:09:10.504760Z",
        "createTime": "2025-12-18T21:09:09.758171Z",
        "state": "STATE_ACTIVE",
        "sizeBytes": "11",
        "mimeType": "text/plain"
    }
  ]
}

@atticoos atticoos force-pushed the fix/uploadFileToFileSearchStore-displayName branch from bcad795 to 4d8fdee Compare December 18, 2025 21:39
@shmishra99 shmishra99 self-assigned this Jan 9, 2026
@shmishra99 shmishra99 added the api: file Issues related to the Filestore API. label Jan 9, 2026
@shmishra99
Copy link
Collaborator

@atticoos , Thank you for raising this PR. I am escalating this PR to team for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: file Issues related to the Filestore API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants