{"record":{"id":"54030b92425eb24d","repo":"conductor-oss/conductor","slug":"invalid-namespace","errorCode":null,"errorMessage":"Invalid namespace","messagePattern":"Invalid namespace","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/vectordb/mongodb/MongoVectorDB.java","lineNumber":82,"sourceCode":"        this.mongoDatabases =\n                CacheBuilder.newBuilder()\n                        .maximumSize(100)\n                        .expireAfterAccess(Duration.ofSeconds(60))\n                        .concurrencyLevel(32)\n                        .build();\n    }\n\n    @Override\n    public int updateEmbeddings(\n            String indexName,\n            String namespace,\n            String doc,\n            String parentDocId,\n            String id,\n            List<Float> embeddings,\n            Map<String, Object> metadata) {\n        if (!pattern.matcher(namespace).matches()) {\n            throw new RuntimeException(\"Invalid namespace\");\n        }\n        if (!pattern.matcher(indexName).matches()) {\n            throw new RuntimeException(\"Invalid index name\");\n        }\n\n        MongoClient client = null;\n        MongoDatabase mongoDatabase = null;\n        try {\n            client = getClient();\n            mongoDatabase = getDatabase(client);\n            // assume collection exists and vector search index applied on it\n            return upsertEmbeddings(\n                    namespace, id, parentDocId, doc, embeddings, metadata, mongoDatabase);\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n    }\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/vectordb/mongodb/MongoVectorDB.java#L64-L100","documentation":"Thrown as a plain RuntimeException by MongoVectorDB.updateEmbeddings when the namespace fails the validation regex [a-zA-Z0-9_-]+. The regex guard prevents NoSQL/SQL injection via collection or namespace identifiers that are interpolated into queries. Only letters, digits, underscore, and hyphen are allowed; no dots, spaces, slashes, or empty strings.","triggerScenarios":"Passing a namespace containing dots (e.g. 'my.ns'), spaces, slashes, special characters, or an empty string to MongoVectorDB.updateEmbeddings.","commonSituations":"Using a dotted namespace convention from another store; passing a URL/UUID with dashes that also contains other chars; trailing/leading whitespace; an empty namespace defaulting from a missing input.","solutions":["Restrict namespace to [a-zA-Z0-9_-] characters only.","Replace dots/spaces/special characters with underscores or hyphens before calling.","Trim whitespace from the namespace input.","Ensure the namespace is non-empty."],"exampleFix":"// before\ndb.updateEmbeddings(\"idx\", \"my.namespace\", ...);  // dot invalid\n// after\ndb.updateEmbeddings(\"idx\", \"my_namespace\", ...);","handlingStrategy":"validation","validationCode":"private static final Pattern VALID = Pattern.compile(\"[a-zA-Z0-9_-]+\");\n// Validate before calling MongoVectorDB\nif (!VALID.matcher(namespace).matches()) {\n    namespace = namespace.replaceAll(\"[^a-zA-Z0-9_-]\", \"_\");\n}","typeGuard":"boolean validNamespace = namespace != null && Pattern.compile(\"[a-zA-Z0-9_-]+\").matcher(namespace).matches();","tryCatchPattern":null,"preventionTips":["Adopt a [a-zA-Z0-9_-] naming convention for namespaces.","Sanitize external identifiers before they reach the vector store.","Document the allowed character set for namespace/index inputs."],"tags":["mongodb","vectordb","validation","injection-guard"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}