{"record":{"id":"67f42d51683913c9","repo":"appsmithorg/appsmith","slug":"organization-with-slug-default-not-found-in-data","errorCode":null,"errorMessage":"Organization with slug 'default' not found in database","messagePattern":"Organization with slug 'default' not found in database","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/client/packages/rts/src/ctl/enable_form_login.ts","lineNumber":37,"sourceCode":"\n  await utils.ensureSupervisorIsRunning();\n\n  let organizationId: string;\n\n  try {\n    // First, check if the organization exists\n    const orgCheckResult = await utils.execCommandReturningOutput([\n      \"mongosh\",\n      dbUrl,\n      \"--eval\",\n      \"db.organization.findOne({slug:'default'},{_id:1,slug:1})\",\n      \"--json\",\n    ]);\n\n    const orgData = JSON.parse(orgCheckResult);\n\n    if (!orgData || !orgData._id) {\n      throw new Error(\"Organization with slug 'default' not found in database\");\n    }\n\n    console.log(\"Found organization:\", orgData.slug);\n\n    // Update the organization to enable form login\n    await utils.execCommand([\n      \"mongosh\",\n      dbUrl,\n      \"--eval\",\n      \"db.organization.updateOne({slug:'default'}, {$set:{'organizationConfiguration.isFormLoginEnabled':true}})\",\n      \"--json\",\n    ]);\n\n    organizationId = orgData._id.$oid;\n    console.log(\"Organization ID:\", organizationId);\n\n    console.log(\"Successfully updated organization configuration\");\n  } catch (error) {","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/client/packages/rts/src/ctl/enable_form_login.ts#L19-L55","documentation":"Thrown after enable_form_login.ts queries MongoDB via mongosh for an organization with slug 'default'. The script runs mongosh --eval \"db.organization.findOne({slug:'default'},{_id:1,slug:1})\" --json and JSON.parses the result; if the parsed object is null or lacks an _id, no default organization exists and the form-login toggle cannot be applied, so it throws.","triggerScenarios":"Running enable-form-login against a database that has no organization document with slug:'default' — e.g. a database initialized differently, a non-default slug, the wrong database selected by the URI, or a fresh DB where the bootstrap that creates the default org has not run.","commonSituations":"Pointing APPSMITH_DB_URL at the wrong database name in the URI; restored backup whose org slug was renamed; multi-tenant install where the default org was deleted; bootstrap migration that creates the default org not yet executed.","solutions":["Verify the MongoDB URI selects the correct database and that a default org exists: run mongosh with the same URI and 'db.organization.findOne({slug:\"default\"})'.","If the default org genuinely does not exist, run the Appsmith bootstrap/initialization that seeds it before enabling form login.","Check whether the org slug was customized and adjust expectations or seed data accordingly.","Confirm mongosh is the same version the script expects so the --json output shape parses (older/newer mongosh can emit different JSON envelopes)."],"exampleFix":"# before\n# db has no {slug:'default'} document\n$ appsmith ctl enable-form-login\n# -> Organization with slug 'default' not found in database\n\n# after\n# seed the default org via the Appsmith bootstrap, then:\n$ appsmith ctl enable-form-login","handlingStrategy":"validation","validationCode":"// pre-check via mongosh before invoking the ctl logic\nconst out = execSync(`mongosh \"${dbUrl}\" --eval \"db.organization.findOne({slug:'default'},{_id:1})\" --json`).toString();\nif (!JSON.parse(out)?._id) throw new Error('Seed the default organization first.');","typeGuard":"const hasOrgId = (o: unknown): o is { _id: string } =>\n  typeof o === 'object' && o !== null && '_id' in o;","tryCatchPattern":"try { await enableFormLogin(); } catch (e) {\n  if (/Organization with slug 'default' not found/i.test(e.message)) { await runBootstrap(); await enableFormLogin(); }\n  else throw e;\n}","preventionTips":["Run the org-seeding bootstrap before any ctl that toggles org settings.","Pin the mongosh version so --json output shape stays stable.","Verify the DB name in the URI points at the right database."],"tags":["database","mongodb","rts","operations","data-integrity"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}