{"record":{"id":"6584a4f3cc4c8024","repo":"usememos/memos","slug":"generalsetting-must-be-populated-for-key-general","errorCode":null,"errorMessage":"generalSetting must be populated for key GENERAL","messagePattern":"generalSetting must be populated for key GENERAL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store/deployment_config.go","lineNumber":226,"sourceCode":"\tif len(config.Scopes) == 0 {\n\t\treturn errors.New(\"config.oauth2Config.scopes is required\")\n\t}\n\tfor i, scope := range config.Scopes {\n\t\tif strings.TrimSpace(scope) == \"\" {\n\t\t\treturn errors.Errorf(\"config.oauth2Config.scopes[%d] must not be empty\", i)\n\t\t}\n\t}\n\tif config.FieldMapping == nil || strings.TrimSpace(config.FieldMapping.Identifier) == \"\" {\n\t\treturn errors.New(\"config.oauth2Config.fieldMapping.identifier is required\")\n\t}\n\treturn nil\n}\n\nfunc validateAndNormalizeDeploymentInstanceSetting(setting *storepb.InstanceSetting) error {\n\tswitch setting.Key {\n\tcase storepb.InstanceSettingKey_GENERAL:\n\t\tif setting.GetGeneralSetting() == nil {\n\t\t\treturn errors.New(\"generalSetting must be populated for key GENERAL\")\n\t\t}\n\t\tif offset := setting.GetGeneralSetting().WeekStartDayOffset; offset < -1 || offset > 6 {\n\t\t\treturn errors.New(\"generalSetting.weekStartDayOffset must be between -1 and 6\")\n\t\t}\n\tcase storepb.InstanceSettingKey_STORAGE:\n\t\tstorage := setting.GetStorageSetting()\n\t\tif storage == nil {\n\t\t\treturn errors.New(\"storageSetting must be populated for key STORAGE\")\n\t\t}\n\t\t// Normalization would silently self-heal this misconfiguration to LOCAL;\n\t\t// a deployment file declaring S3 without a config should fail loudly.\n\t\tif storage.StorageType == storepb.InstanceStorageSetting_S3 && storage.S3Config == nil && len(storage.Storages) == 0 {\n\t\t\treturn errors.New(\"storageSetting.s3Config is required for S3\")\n\t\t}\n\t\tNormalizeInstanceStorageSetting(storage)\n\t\tif storage.UploadSizeLimitMb < 0 {\n\t\t\treturn errors.New(\"storageSetting.uploadSizeLimitMb must not be negative\")\n\t\t}","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/store/deployment_config.go#L208-L244","documentation":"Thrown when an instance-setting deployment file (memos-instance-setting-*.json) declares \"key\": \"GENERAL\" but carries no generalSetting message (setting.GetGeneralSetting() == nil). The oneof payload must match the declared key; an empty or mismatched payload means the setting would be a no-op, so validation fails and the file is reported as an invalid instance setting deployment file at startup.","triggerScenarios":"A memos-instance-setting-general.json containing only { \"key\": \"GENERAL\" }, or whose payload key is spelled differently (e.g. \"general_setting\", \"general\") so protojson leaves the oneof unset.","commonSituations":"Authoring the file from a proto dump where the payload key got dropped; using snake_case field names inconsistent with protojson; intending to configure a different key but leaving \"key\": \"GENERAL\".","solutions":["Add a \"generalSetting\" object matching the declared key, e.g. { \"key\": \"GENERAL\", \"generalSetting\": { \"weekStartDayOffset\": 0 } }.","Verify the payload field name is exactly generalSetting (lowerCamelCase protojson).","If you meant a different setting, change \"key\" and the payload together."],"exampleFix":"// before\n{ \"key\": \"GENERAL\" }\n\n// after\n{ \"key\": \"GENERAL\", \"generalSetting\": { \"weekStartDayOffset\": 1 } }","handlingStrategy":"validation","validationCode":"if setting.Key == storepb.InstanceSettingKey_GENERAL && setting.GetGeneralSetting() == nil {\n    return errors.New(\"GENERAL setting requires a generalSetting payload\")\n}","typeGuard":"func payloadMatchesKey(s *storepb.InstanceSetting) bool {\n    switch s.GetKey() {\n    case storepb.InstanceSettingKey_GENERAL:\n        return s.GetGeneralSetting() != nil\n    default:\n        return false\n    }\n}","tryCatchPattern":null,"preventionTips":["Write key and payload as one unit; never edit one without the other.","Use the admin UI's export or an API GET on the setting as the skeleton for the deployment file."],"tags":["configuration","validation","instance-setting","startup"],"backgroundTag":null,"analyzedSha":"14d757ce1fb31c78590f374bc042f8dbedbc20d7","analyzedAt":"2026-08-15T09:27:36.538Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}