{"record":{"id":"a1169b39bf374ae1","repo":"usememos/memos","slug":"generalsetting-weekstartdayoffset-must-be-between","errorCode":null,"errorMessage":"generalSetting.weekStartDayOffset must be between -1 and 6","messagePattern":"generalSetting\\.weekStartDayOffset must be between -1 and 6","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store/deployment_config.go","lineNumber":229,"sourceCode":"\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}\n\t\tdefaultStorage := GetDefaultStorage(storage)\n\t\tif defaultStorage != nil && defaultStorage.Type == storepb.StorageType_STORAGE_TYPE_S3 {\n\t\t\ts3Config := defaultStorage.GetS3Config()","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/store/deployment_config.go#L211-L247","documentation":"Thrown when a GENERAL instance-setting deployment file sets generalSetting.weekStartDayOffset outside the accepted range of -1 to 6 inclusive (-1 typically means browser-default; 0-6 map to Sunday-Saturday). Out-of-range values would produce undefined calendar behavior in the UI, so the deployment loader rejects the file at startup.","triggerScenarios":"A memos-instance-setting-general.json with \"weekStartDayOffset\": 7, a negative value below -1, or a copy-paste where the offset is treated as 1-based (e.g. 7 for Saturday).","commonSituations":"Converting from a locale string (e.g. ISO week starting Monday = 1) and off-by-one mistakes; feeding a day name or boolean instead of the integer enum.","solutions":["Set weekStartDayOffset to -1 (browser default) or 0-6 (Sunday through Saturday).","Double-check the mapping in the admin UI's Week start setting and mirror that integer."],"exampleFix":"// before\n{ \"key\": \"GENERAL\", \"generalSetting\": { \"weekStartDayOffset\": 7 } }\n\n// after\n{ \"key\": \"GENERAL\", \"generalSetting\": { \"weekStartDayOffset\": 6 } }","handlingStrategy":"validation","validationCode":"if offset := setting.GetGeneralSetting().GetWeekStartDayOffset(); offset < -1 || offset > 6 {\n    return fmt.Errorf(\"weekStartDayOffset %d out of range [-1,6]\", offset)\n}","typeGuard":"func isValidWeekStartDayOffset(offset int32) bool { return offset >= -1 && offset <= 6 }","tryCatchPattern":null,"preventionTips":["Remember the encoding: -1 = browser default, 0 = Sunday, 6 = Saturday.","Set the value once via the admin UI and copy the resulting integer into 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"}