Skip to content

driver-mongodb's published README teaches a spec-REFUSED field key and promises an index authored metadata never gets — it ships to npm #13223

Description

@os-zhuang

Found by the #12252 dev while measuring the fixture census; reported rather than swept, and filed here by the domain:engine PM seat.

What ships

packages/drivers/driver-mongodb/README.md:172, inside a worked example:

company_id: {type: 'lookup',reference_to: 'company'},

followed by:

// Creates: idx_id_unique, idx_name_unique, idx_email, idx_company_id_lookup

README.md is in this package's files array, so this is published to npm — user-facing instruction, not internal test data.

Two defects in one eight-line sample

1. It teaches a key the spec refuses.reference is the only relationship spelling FieldSchema declares; reference_to fails safeParse with unrecognized_keys (measured on origin/main, #12252). A reader who copies this sample writes an object that cannot be published.

2. The promised index is not produced for a correctly-authored object. Differential probe against the real syncCollectionSchema (#13222): with reference_to the index appears; with the canonical reference it does not, because mongodb-schema.ts:112-113 gates the lookup arm on reference_to. So the comment is true only of the spelling the spec rejects — for anything a user can actually author, idx_company_id_lookup is never created.

The sample is therefore self-consistent only in a state no user can reach: it teaches the wrong key, and its stated outcome depends on that wrongness.

Why it is filed separately from #13222

⚠️ This is wrong whichever way #13222 is ruled, so it must not wait on it:

Either way the published spelling must change. Only the trailing // Creates: line's fate depends on #13222.

Deliverable

Correct the sample to reference, and make the // Creates: comment state what an authored object actually gets today — i.e. drop idx_company_id_lookup from the list unless and until #13222 lands, ⚠️ rather than leaving a promise the driver does not keep. ⛔ Do not fix this by changing the driver here; that is #13222's decision.

Worth checking the other driver READMEs for the same copied sample while in there — ⛔ report anything found rather than widening this card.

Priority

Graded priority:p1 despite being "just docs": this is the material an AI author copies, it is the repo's one worked example of a MongoDB lookup, and it is already on npm. The in-repo fixture version of this same mistake (#12252) is graded p2 precisely because it is not published.

Related

#13222 (the driver defect this sample documents) · #12252 (the fixture census that surfaced it) · #12251 (closed not_planned)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentationdomain:enginepriority:p1High: required for production / M2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions