Repository navigation
fix(search): accept unknown future SearchIndexStatus values (MZ-17) - #15
Merged
Merged
Conversation
Align the public SearchIndexStatus type with the runtime passthrough of unknown server statuses. Export KnownSearchIndexStatus for documented literals, keep wait defaults and READY/queryable semantics unchanged, and cover the contract with tsd, unit, and bilingual docs.
Contributor
Author
独立复审 R1 — MZ-17 (PR #15)结论:REQUEST_CHANGES(1 项 P2 文档契约不一致;未发现核心类型实现阻断) 已核验且认可
P2 / 需要修复:英文/中文新加说明与实际 wait 策略矛盾
R2 通过条件
其他 MZ-02/03/06/07/09/13 问题属于独立工作,本 PR 不要求顺带实现。 注:本条为独立复审 R1 记录,需按上述项修复后再考虑合并。 |
Split the queryable, ready, and dropped wait conditions so they match operations.ts. Note that SearchIndexStatus can type an empty string while normalizeSearchIndexInfo still maps empty, missing, or non-string input to PENDING. Runtime wait logic is unchanged.
Contributor
Author
独立复审 R2 — PASS(MZ-17)复审基线:base R1 返工核对
证据
R2 判定:PASS,无 P0/P1/P2 阻断。建议 squash merge main。 不发布 npm、不打 Tag、不改变版本。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MZ-17: the public
SearchIndexStatustype was a closed seven-literal union, whilenormalizeSearchIndexInfoalready passes unknown future server statuses through unchanged (only missing/empty/non-string values becomePENDING). This made legal runtime values unrepresentable in TypeScript.Design decision (candidate A): introduce
KnownSearchIndexStatusfor the documented literals and defineSearchIndexStatus = KnownSearchIndexStatus | (string & {}). Autocomplete is preserved; unknown strings such asPAUSED_BY_SERVERare assignable. Unknown values are never rewritten toPENDING.waitForSearchIndexdefaults and READY / queryable semantics are unchanged.Rejected candidate B (
status: SearchIndexStatus | (string & {})only onSearchIndexInfo, leavingSearchIndexStatusclosed) because standalone uses of the public status type would still reject future values. Rejected candidate C (status: string) because it drops literal autocomplete.isKnownSearchIndexStatusis now a type predicate and is re-exported from the internal search-indexes barrel for unit tests only. It is not a new public runtime API (confirmed absent fromdist/cjs/index.cjs/ package exports). A public runtime guard can be considered later if reviewers want it.No version bump, no npm publish, no GitHub Actions changes.
SHAs
main):80da4d733be421a6ea8e68daca6c101e62268a2881a7d2195e9e973de9e1dae0df4265ece03a909aFile changes
types/search-index.d.ts—KnownSearchIndexStatus+ openSearchIndexStatussrc/adapters/mongodb/search-indexes/types.ts— re-export the new typesrc/adapters/mongodb/search-indexes/normalize.ts— drop theas SearchIndexStatusassertion; type-guard predicatesrc/adapters/mongodb/search-indexes/index.ts— internal export of the helper (tests only)test/types/search-index-usage.test-d.ts— future status assignable; known union still rejects ittest/unit/search-indexes/search-indexes.test.ts— passthrough, known literals, empty/missing →PENDING, wait behavior for unknown statusdocs/en/search-indexes.md,docs/zh/search-indexes.mdchangelogs/unreleased.md— candidate note only; package remains 3.5.3Tests actually run (this machine)
Environment: Linux, Node
v24.22.1, npm11.21.1, localmongodbdriver6.21.0(from this checkout’s package). Commands run after the commit contents were in the working tree;distwas produced bynpm run buildon this branch.All of the commands above exited 0. GitHub Actions CI for this PR is not claimed here; it will run after open.
Not run on this PR (out of scope / no environment): Search/Vector Search real deployments (Atlas, atlas-local, Community+mongot, Enterprise+mongot); Node 18/20/22 × Driver 6/7 × MongoDB 7/8 matrix. Those remain on
mainevidence for SHA80da4d7as documented in the handoff, and should be judged from this PR’s CI jobs once they finish.Risks
KnownSearchIndexStatus(compatible). ExistingSearchIndexStatusremains assignable from the seven literals.switchonSearchIndexStatusin downstream TypeScript may now require a default branch. That is the intended correction.FAILEDorREADY;until: 'queryable'still succeeds whenqueryable === true.Please do not merge yet
This PR is ready for independent review (ChatGPT / R1). Do not merge until that review passes and the existing merge authorization is applied by the reviewer.
Note
Low Risk
Additive typing and documentation; runtime wait/queryable semantics are unchanged aside from clearer tests and docs. Downstream exhaustive switches on
SearchIndexStatusmay need a default branch.Overview
MZ-17 aligns the public TypeScript model with runtime behavior: server-reported search index statuses are no longer limited to a closed seven-literal union.
A new exported type
KnownSearchIndexStatusholds the documented literals, whileSearchIndexStatusbecomesKnownSearchIndexStatus | (string & {})so values likePAUSED_BY_SERVERare typable without losing autocomplete on known statuses. Normalization still maps only empty, missing, or non-string statuses toPENDING; unknown strings pass through unchanged.isKnownSearchIndexStatusis now a type predicate and is exposed only on the internal adapter barrel for tests.Type tests, unit coverage for passthrough and
waitForSearchIndexwith unknown statuses, bilingual Search docs, and an unreleased changelog note accompany the type/export tweaks.Reviewed by Cursor Bugbot for commit 8eec9f1. Bugbot is set up for automated code reviews on this repo. Configure here.