{"record":{"id":"6c3459398b66e626","repo":"Budibase/budibase","slug":"actiontype-query-extra-actiontype-does-not-exis","errorCode":null,"errorMessage":"actionType ${query.extra.actionType} does not exist on DB for create","messagePattern":"actionType (.+?) does not exist on DB for create","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/integrations/mongodb.ts","lineNumber":494,"sourceCode":"    query: MongoDBQuery\n  ): Promise<InsertOneResult | InsertManyResult> {\n    try {\n      await this.connect()\n      const db = this.client.db(this.config.db)\n      const collection = db.collection(query.extra.collection)\n      let json = this.createObjectIds(query.json)\n\n      // For mongodb we add an extra actionType to specify\n      // which method we want to call on the collection\n      switch (query.extra.actionType) {\n        case \"insertOne\": {\n          return await collection.insertOne(json)\n        }\n        case \"insertMany\": {\n          return await collection.insertMany(json)\n        }\n        default: {\n          throw new Error(\n            `actionType ${query.extra.actionType} does not exist on DB for create`\n          )\n        }\n      }\n    } catch (err) {\n      console.error(\"Error writing to mongodb\", err)\n      throw err\n    } finally {\n      await this.client.close()\n    }\n  }\n\n  async read(query: MongoDBQuery): Promise<NonNullable<unknown>> {\n    try {\n      await this.connect()\n      const db = this.client.db(this.config.db)\n      const collection = db.collection(query.extra.collection)\n      let json = this.createObjectIds(query.json)","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/integrations/mongodb.ts#L476-L512","documentation":"MongoDB integration's create() switches on query.extra.actionType to choose insertOne or insertMany. If the actionType is neither, the default branch throws 'actionType <X> does not exist on DB for create', meaning the JSON action sent to the connector is not a supported create operation.","triggerScenarios":"Executing a MongoDB query in Budibase whose configured create actionType is misspelled, empty, or an action that belongs to read/update/delete (e.g. 'find', 'updateOne') — anything outside { insertOne, insertMany }.","commonSituations":"Hand-edited or imported query definitions with an invalid actionType; REST-like payloads copied from a different datasource; version drift where a query was built against different action names.","solutions":["Set query.extra.actionType to exactly \"insertOne\" or \"insertMany\" for create queries","Re-create the query in the Budibase builder so it emits a valid actionType","Validate the JSON payload's actionType before executing (whitelist check)","Check for typos/case mismatches (e.g. 'InsertOne' vs 'insertOne')"],"exampleFix":"// before\nconst query = { table: \"users\", json: { name: \"x\" }, extra: { actionType: \"insert\" } }\n// after\nconst query = { table: \"users\", json: { name: \"x\" }, extra: { actionType: \"insertOne\" } }","handlingStrategy":"validation","validationCode":"const CREATE_ACTIONS = [\"insertOne\", \"insertMany\"]\nif (!CREATE_ACTIONS.includes(query.extra?.actionType)) {\n  throw new Error(`Invalid create actionType: ${query.extra?.actionType}`)\n}\nawait ds.create(query)","typeGuard":"function isCreateAction(t: unknown): t is \"insertOne\" | \"insertMany\" {\n  return t === \"insertOne\" || t === \"insertMany\"\n}","tryCatchPattern":"try {\n  await ds.create(query)\n} catch (err) {\n  if (err.message.includes(\"does not exist on DB for create\")) {\n    throw new Error(`Unsupported MongoDB create action \"${query.extra?.actionType}\"; use insertOne or insertMany`, { cause: err })\n  }\n  throw err\n}","preventionTips":["Only build MongoDB queries through the builder so actionType is generated correctly","Whitelist actionType before dispatching hand-built JSON payloads","Watch for case-sensitive typos in action names","Re-validate queries after migrating or editing definitions by hand"],"tags":["mongodb","action-type","create","validation"],"backgroundTag":"unsupported-operation","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}