{"record":{"id":"ceac6884902e3883","repo":"toeverything/AFFiNE","slug":"invalid-app-config-input-ceac68","errorCode":"invalid_app_config_input","errorMessage":"Invalid app config input: ${message}","messagePattern":"Invalid app config input: (.+?)","errorType":"validation","errorClass":"InvalidAppConfigInput","httpStatus":400,"severity":"error","filePath":"packages/backend/server/src/data/commands/import.ts","lineNumber":52,"sourceCode":"      }\n\n      Object.entries(config).forEach(([key, value]) => {\n        forValidation.push({\n          module,\n          key,\n          value,\n        });\n        forSaving.push({\n          key: `${module}.${key}`,\n          value,\n        });\n      });\n    });\n\n    const errors = this.configFactory.validate(forValidation);\n\n    if (errors?.length) {\n      throw new InvalidAppConfigInput({\n        message: errors.map(error => error.message).join('\\n '),\n      });\n    }\n\n    // @ts-expect-error null as user id\n    await this.models.appConfig.save(null, forSaving);\n  }\n}\n","sourceCodeStart":34,"sourceCodeEnd":61,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/data/commands/import.ts#L34-L61","documentation":"Thrown by ImportConfigCommand after configFactory.validate(forValidation) returns errors — one or more module.key/value entries in the imported JSON file failed server-side config validation. The thrown message aggregates each validation error message separated by newlines.","triggerScenarios":"Running the config import command with a JSON whose module names or keys don't match known config modules, or whose values fail type/schema validation for that key.","commonSituations":"Hand-edited config JSON with a typo'd module or key name; values exported from a different AFFiNE version whose config schema changed; JSON numbers where booleans/strings are expected.","solutions":["Read the joined messages in the error — each line names the failing constraint; fix the corresponding module/key/value in the JSON.","Check the $schema entry at the top of the file (or the published config schema) for the exact module and key names available in your server version.","Re-export a known-good config from a server of the same version and diff it against your file."],"exampleFix":"// before (config.json)\n{\n  \"$schema\": \"...\",\n  \"affine\": { \"enableDeletedDoc\": \"yes\" }\n}\n// after\n{\n  \"$schema\": \"...\",\n  \"affine\": { \"enableDeletedDoc\": true }\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate against the same factory before saving\nconst errors = configFactory.validate(forValidation);\nif (errors?.length) {\n  console.error(errors.map(e => e.message).join('\\n'));\n  process.exitCode = 1; // fix file before importing\n}","typeGuard":null,"tryCatchPattern":"try {\n  await importConfigCommand.execute(path);\n} catch (e) {\n  if (getErrorCode(e) === 'invalid_app_config_input') {\n    // e.message lists every failing module.key — print and fix the JSON\n    console.error(e.message);\n  }\n}","preventionTips":["Validate the config JSON with configFactory.validate (or the published $schema) in CI before import.","Keep a known-good exported config of the matching server version as the editing baseline."],"tags":["cli","config","validation","import"],"backgroundTag":"invalid-config-value","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}