{
  "id": "mongodb/change-stream-invalid-json",
  "signature": "MongoServerError: Change stream pipeline must be a valid JSON array: invalid JSON input at position 10",
  "signature_zh": "MongoServerError: 变更流管道必须是有效的 JSON 数组：位置 10 处无效的 JSON 输入",
  "regex": "Change stream pipeline must be a valid JSON array: invalid JSON input at position \\d+",
  "domain": "mongodb",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The change stream pipeline argument was passed as an invalid JSON string or malformed array, often due to string concatenation errors in application code.",
  "root_cause_type": "generic",
  "root_cause_zh": "变更流管道参数作为无效的 JSON 字符串或格式错误的数组传递，通常是由于应用程序代码中的字符串拼接错误。",
  "versions": [
    {
      "version": "MongoDB 5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MongoDB 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MongoDB 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding extra quotes around the pipeline array does not fix the JSON parsing; it causes additional syntax errors.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using a string instead of an array for the pipeline (e.g., '[{\"$match\": {}}]') is parsed as a string literal, not an array.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the pipeline is passed as a native array object, not a JSON string. In Node.js: db.collection.watch([{$match: {operationType: 'insert'}}]). In Python: db.collection.watch([{'$match': {'operationType': 'insert'}}]).",
      "success_rate": 0.95,
      "how": "Ensure the pipeline is passed as a native array object, not a JSON string. In Node.js: db.collection.watch([{$match: {operationType: 'insert'}}]). In Python: db.collection.watch([{'$match': {'operationType': 'insert'}}]).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Validate the pipeline JSON using JSON.parse() in JavaScript or json.loads() in Python before passing it to the watch method.",
      "success_rate": 0.9,
      "how": "Validate the pipeline JSON using JSON.parse() in JavaScript or json.loads() in Python before passing it to the watch method.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保管道作为原生数组对象传递，而不是 JSON 字符串。在 Node.js 中：db.collection.watch([{$match: {operationType: 'insert'}}])。在 Python 中：db.collection.watch([{'$match': {'operationType': 'insert'}}])。",
    "在将管道传递给 watch 方法之前，使用 JavaScript 中的 JSON.parse() 或 Python 中的 json.loads() 验证管道 JSON。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.mongodb.com/docs/manual/changeStreams/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-04-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}