Skip to content

fix(files_metadata): chunk file id list in getMetadataFromFileIds - #64608

Open
shawon9324 wants to merge 6 commits into
nextcloud:masterfrom
shawon9324:fix/files-metadata-chunk-get-by-file-ids
Open

shawon9324 wants to merge 6 commits into
nextcloud:masterfrom
shawon9324:fix/files-metadata-chunk-get-by-file-ids

Conversation

@shawon9324

Copy link
Copy Markdown

Summary

getMetadataFromFileIds() currently passes the complete list of file IDs into a single IN() clause. When the list exceeds IQueryBuilder::MAX_IN_PARAMETERS, QueryBuilder logs an error for the oversized parameter list but still proceeds with the query. This can cause repeated error logging during operations such as PROPFIND on directories containing more than 1000 files, and can escalate to an actual query failure when backend-specific parameter limits are reached.

The issue originates before normal database execution because the complete array is passed to createNamedParameter() as PARAM_INT_ARRAY. QueryBuilder detects arrays larger than IQueryBuilder::MAX_IN_PARAMETERS and logs the condition, while PostgreSQL can genuinely fail at sufficiently large parameter counts due to its protocol parameter-count limit, and Oracle has a database-level limit of 1000 expressions in an IN() list.

This change splits the file ID list into chunks of IQueryBuilder::MAX_IN_PARAMETERS, executes one query per chunk, and merges the resulting metadata into the same return array. This follows the existing chunking pattern already used by dropMetadataForFiles() and avoids introducing a separate query strategy or architectural change. Tests were added to verify both parameter chunking and that results from multiple chunks are merged correctly.

The issue report mentions both getMetadataFromFileIds() and dropMetadataForFiles(). I verified that dropMetadataForFiles() is already chunking its input correctly and already has coverage through testDropMetadataForFilesChunking(). Therefore, only getMetadataFromFileIds() still required a fix.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

getMetadataFromFileIds() passed the full file id array into a single
IN() expression. QueryBuilder rejects lists above MAX_IN_PARAMETERS,
so PROPFIND on directories with more than 1000 files failed with a
query exception. Query the ids in chunks, matching dropMetadataForFiles().

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: shawon9324 <shawon9324@gmail.com>
Copilot AI lite review requested due to automatic review settings September 21, 2026 06:37
@shawon9324
shawon9324 requested a review from a team as a code owner September 21, 2026 06:37
@shawon9324
shawon9324 requested review from Altahrim, come-nc, leftybournes and salmart-dev and removed request for a team September 21, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Successfully merging this pull request may close these issues.

[Bug]: FilesMetadataService fails with large file ID arrays in MetadataRequestService

2 participants