Mongo tools silently accept a wrong database name and misreport `{collection, find}` commands as "undefined" or as permission denials
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- mongodb, sql, typescript
- Domaine
- databases
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 812
- Forks
- 123
- Merge moyen
- 1 j 16 h
- PR mergées (30 j)
- 83
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de AltimateAI/altimate-code
-
fix(workspace): don't offer the engine install when a workspace declares no integration toolsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
AltimateAI/altimate-code#1593 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
AltimateAI/altimate-code#1591 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
AltimateAI/altimate-code#1590 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 69/100
AltimateAI/altimate-code#1588 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
AltimateAI/altimate-code#1573 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de AltimateAI/altimate-code
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
awslabs/visual-asset-management-system#804 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
restatedev/sdk-typescript#813 ·
-
bug desktop P1 session XS
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Merit-Systems/x402scan#1312 ·
-
type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Azure/apiops-cli#331 ·
Les mainteneurs répondent en général sous 3 jours