issue-142: Implement the mongo_list_collections tool with unit tests #159
No reviewers
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills!159
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-142/implement-the-mongo-list-collections-tool-with-uni"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
142: Implement the mongo_list_collections tool with unit tests
Implements 142.
Generated in 5m 17s.
Review findings
Now let me check the repo's git state, AGENTS.md conventions, and how the build/test gates are configured.The working tree is clean and the Stage 1 change is commit
7bbeb15. Now I understand the full picture. Let me apply the Medium finding fix totestClient.ts— making thelistCollectionsmock throw driver errors from the cursor'stoArray()(async), keeping a synchronous throw only forMongoInvalidArgumentError, mirroring the real driver.Now let me verify the change and discover the project's build/test gates (root package.json, Makefile, etc.).The change looks correct. Now let me run the project gates: the mongodb extension tests, its TypeScript check, and the root test suite (all discovered from package.json scripts).Mongodb tests pass (89/0) andtsc --noEmitis clean. Now the root test suite:All gates pass. Let me confirm the final working-tree diff is exactly the intended change.All gates pass and the working-tree diff contains exactly the intendedtestClient.tschange. Here is the annotated findings document.Review Findings — 142
Summary
The branch (
feature/issue-142/..., commit7bbeb15) adds three error-path unit tests toextensions/mongodb/src/tools/listCollections.test.ts(invalid-query / server / unexpected categories), completing the five-category error coverage the extension's DESIGN.md requires for each tool. Note: themongo_list_collectionsimplementation itself (src/tools/listCollections.ts) is already merged onorigin/main(it landed in issue 139's PR), so this PR is test-only. Gates run:bun test(extensions/mongodb) — PASS (89 pass / 0 fail, including all 8 listCollections tests);bun run check(tsc --noEmit) — PASS; rootnpm test— PASS (58 pass, unrelated local-install tests); lint — N/A (the repo has no lint tooling configured — no eslint/biome/prettier configs or scripts). No critical or high findings; one medium test-fidelity gap and one low convention nit.Remediation (single pass): the medium test-fidelity gap is fixed —
extensions/mongodb/src/tools/testClient.tsnow makes thelistCollectionsmock return a cursor whosetoArray()throws the configured driver error (async rejection, mirroring thefindfake and the real driver), keeping a synchronous throw only forMongoInvalidArgumentError. Gates re-run after the fix:bun test(extensions/mongodb) PASS (89/0),bun run checkPASS, rootnpm testPASS (58/0). The low convention nit remains unresolved — the commit message cannot be amended in this pipeline stage (no git commit/amend allowed; the captured diff cannot carry a commit-message change), and rewriting AGENTS.md's repo-wide commit convention is a repo-owner decision outside this test-only PR.Critical
High
Medium
extensions/mongodb/src/tools/listCollections.test.ts:128(also:109,:145) — The three new error tests (and the two pre-existing connection/auth tests they sit beside) exercise the shared fake's synchronous throw fromdb.listCollections()(extensions/mongodb/src/tools/testClient.ts:65-71), but the real driver surfaces server/network/auth errors only as an async rejection from the cursor'stoArray()(synchronous throws are reserved for argument-validation errors likeMongoInvalidArgumentError). Thefindfake deliberately throws fromtoArray()"mirroring the real driver" (see the testClient.ts header comment), and DESIGN.md's Testing Strategy documents the same rationale — so a regression that movesawait …toArray()outside the tool'stryblock would pass these tests even though it would leak a rawMongoServerErrorin production. Suggested fix: intestClient.ts, make thelistCollectionsmock return a cursor whosetoArray()throws the configured error (mirroring thefindfake), keeping a synchronous throw only forMongoInvalidArgumentError; the server/auth/connection assertions then validate the real async path.Low
extensions/mongodb/src/tools/listCollections.test.ts:1(commit7bbeb15) — Commit message is142: Implement the mongo_list_collections tool with unit tests, but AGENTS.md specifies the formatissue-<N>: <summary>(e.g.issue-42: add user auth); theissue-prefix is missing. (This matches the actual merged history for issues 139–141, so the doc and the practice are out of sync.) Suggested fix: amend the commit message toissue-142: Implement the mongo_list_collections tool with unit tests, or update AGENTS.md's commit convention to match the repo's established<N>:form.