Skip to content

fix(NODE-7764): use $eq to match file IDs in GridFS queries - #5068

Open
tadjik1 wants to merge 1 commit into
mainfrom
NODE-7764
Open

tadjik1 wants to merge 1 commit into
mainfrom
NODE-7764

Conversation

@tadjik1

@tadjik1 tadjik1 commented Oct 1, 2026

Copy link
Copy Markdown
Member

Description

Summary of Changes

Sync spec tests and modify query filter format.

What is the motivation for this change?

Align with updated specification.

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@tadjik1
tadjik1 marked this pull request as ready for review October 1, 2026 09:21
Copilot AI balanced review requested due to automatic review settings October 1, 2026 09:21
@tadjik1
tadjik1 requested a review from a team as a code owner October 1, 2026 09:21

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 review overview

🟢 Approval recommended

The implementation consistently applies $eq across affected GridFS operations and includes comprehensive specification coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Aligns GridFS file-ID queries with the updated specification, preventing operator-shaped IDs from being interpreted as query operators.

Changes:

  • Wraps GridFS ID matches in $eq for downloads, deletes, renames, chunk reads, and upload aborts.
  • Adds unified and prose coverage for query injection scenarios.
  • Synchronizes retryable-read fixtures and GridFS documentation.
File Description
src/​gridfs/​download.ts Uses $eq for file and chunk lookups.
src/​gridfs/​index.ts Uses $eq for download, delete, and rename filters.
src/​gridfs/​upload.ts Safely matches chunk IDs during abort cleanup.
test/​integration/​gridfs/​gridfs.prose.test.ts Tests abort cleanup with an operator-shaped ID.
test/​spec/​gridfs/​README.md Adds the new prose test specification.
test/​spec/​gridfs/​queries-use-eq.yml Adds YAML unified tests for $eq behavior.
test/​spec/​gridfs/​queries-use-eq.json Adds equivalent JSON unified tests.
test/​spec/​retryable-reads/​unified/​gridfs-download.yml Updates expected download command filters.
test/​spec/​retryable-reads/​unified/​gridfs-download.json Updates generated JSON expectations.
test/​spec/​retryable-reads/​unified/​gridfs-download-serverErrors.yml Updates server-error retry expectations.
test/​spec/​retryable-reads/​unified/​gridfs-download-serverErrors.json Updates generated server-error expectations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@johnmtll johnmtll 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.

Looks good! Just missing the release highlight & one outstanding question. (test failures are sfp failure so i ignored them)

Comment thread src/gridfs/download.ts
? stream.s.filter._id.toString()
: stream.s.filter.filename;
const identifier =
stream.s.filter._id != null ? String(stream.s.filter._id.$eq) : stream.s.filter.filename;

@johnmtll johnmtll Oct 1, 2026 •

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.

What's the reason for switching from .toString() to String()? Unlike before, a nullish value now gives "null"/"undefined" instead of throwing.

This branch has not been deployed

No deployments
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.

3 participants