Mongo tools silently accept a wrong database name and misreport `{collection, find}` commands as "undefined" or as permission denials
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- mongodb, sql, typescript
- 领域
- databases
调研方向
Start with normalizeMqlCommand in packages/drivers/src/mongodb.ts (around lines 79-102), which only rewrites string-valued native keys, and the resolveDb lookup near lines 241 and 413. Then read MONGO_READ_COMMANDS and the write fallback in packages/opencode/src/altimate/tools/sql-classify.ts, plus the error path in sql-materialize.ts around lines 180-185. Done when the acceptance checks in the issue pass: the collection/find shape matches the canonical form, a wrong database name lists valid databases, and listCollections is classified as a read.
由索引模型根据 Issue 内容生成。
描述
Problem
- A command containing the wrong
databasename silently targets an empty database and returns "0 rows and no column information", which looks like a legitimate empty result. - The natural shape
{"collection": "articles", "find": {...}}(or"aggregate": [...]) is not normalised.sql_materializesaysMongoDB command "undefined" is not allowed;sql_executetreats it as a write and returns "The user has specified a rule which prevents you from using this specific tool call". listCollectionsis classified as a write; SQL text sent to a Mongo warehouse is denied as a permission problem instead of "this is MongoDB, use a JSON command".
Mechanism
normalizeMqlCommandonly rewrites native keys whose value is a string (packages/drivers/src/mongodb.ts:79-102), socommandstays undefined whenfindis an object.resolveDb(parsed.database)accepts any name (mongodb.ts:241-243,:413); no existence check.sql_materializeerror:sql-materialize.ts:180-185.sql_executepath:MONGO_READ_COMMANDSlackslistCollectionsandestimatedDocumentCount(packages/opencode/src/altimate/tools/sql-classify.ts:197), and an unparseable shape falls into the write path (:216-220).
Evidence
Recorded analyst sessions against a 127k-document collection:
- 7 silent empty reads (5 used the warehouse name as the database; 2 a nonexistent collection).
- 31
sql_materializecalls reported command "undefined" in one set of sessions (16 in another, 4 in a third) and 9sql_executecalls returned the permission text; it was the first Mongo call in all 10 sessions of one batch. - 9 SQL-on-Mongo permission denials.
Most sessions recovered after one turn; the silent empty read can silently corrupt an answer.
Impact
Correctness-risk (silent empty result) plus about one wasted turn per occurrence.
Proposed fix
- Accept
{collection, find: <filter>}and{collection, aggregate: <pipeline>}. - Validate
databaseand collection once per connection (listCollections/listDatabases) and return the available names on mismatch. - Add
listCollectionsandestimatedDocumentCountto the read commands. - Return a shape error, never a permission error, for unparseable Mongo input or SQL sent to Mongo.
Acceptance check
{"collection":"c","find":{"a":1}}runs identically to{"command":"find","collection":"c","filter":{"a":1}}in both tools.- A wrong database name returns an error listing valid databases, not an empty result.
listCollectionsis classified as a read.
- 主要语言
- TypeScript
- 星标
- 810
- 派生
- 121
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 89
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AltimateAI/altimate-code 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
AltimateAI/altimate-code#1454 ·
维护者通常 1 天内回复
-
test: MCP tests fail when the developer's ~/.claude.json has MCP servers (HOME is not sandboxed)未关闭
难度 2/5 1-3 小时 新手友好度 78/100
AltimateAI/altimate-code#1386 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
AltimateAI/altimate-code#1384 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
AltimateAI/altimate-code#1323 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
AltimateAI/altimate-code#1288 ·
维护者通常 1 天内回复
查看 AltimateAI/altimate-code 的全部 Issue
相似的 Issue
-
Object parameters lose their structure when resources is enabled可能已有人在做 @asts-top 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
jaegertracing/jaeger-ui#4618 ·
维护者通常 1 天内回复
-
pending close triaging
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#56765 · 1 条评论 ·
维护者通常 1 天内回复
-
area:plugins enhancement platform:vscode
难度 2/5 1-3 小时 新手友好度 88/100
anthropics/claude-code#103166 ·
维护者通常 1 天内回复
-
Types: FlashListProps imports ViewabilityConfig from react-native, removed in RN 0.87+可能已有人在做 @efegokdemir 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Shopify/flash-list#2540 ·