{"record":{"id":"f4f2016b81eff56e","repo":"usememos/memos","slug":"storagesetting-uploadsizelimitmb-must-not-be-negat","errorCode":null,"errorMessage":"storageSetting.uploadSizeLimitMb must not be negative","messagePattern":"storageSetting\\.uploadSizeLimitMb must not be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store/deployment_config.go","lineNumber":243,"sourceCode":"\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()\n\t\t\tif s3Config == nil {\n\t\t\t\treturn errors.New(\"storageSetting default storage S3 config is required\")\n\t\t\t}\n\t\t\tfor _, field := range []struct {\n\t\t\t\tname  string\n\t\t\t\tvalue string\n\t\t\t}{\n\t\t\t\t{name: \"accessKeyId\", value: s3Config.AccessKeyId},\n\t\t\t\t{name: \"accessKeySecret\", value: s3Config.AccessKeySecret},\n\t\t\t\t{name: \"endpoint\", value: s3Config.Endpoint},\n\t\t\t\t{name: \"region\", value: s3Config.Region},\n\t\t\t\t{name: \"bucket\", value: s3Config.Bucket},\n\t\t\t} {\n\t\t\t\tif strings.TrimSpace(field.value) == \"\" {","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/store/deployment_config.go#L225-L261","documentation":"Thrown during STORAGE instance-setting validation when storageSetting.uploadSizeLimitMb is negative. The field is optional (0 means server default) but a negative limit is meaningless; validation runs after NormalizeInstanceStorageSetting, so a normalizer that produced a negative value from malformed input would also surface here. The deployment file is rejected at startup.","triggerScenarios":"A memos-instance-setting-storage.json with \"uploadSizeLimitMb\": -1 or a templating bug rendering a negative number.","commonSituations":"Using -1 as an 'unlimited' sentinel (not supported here); arithmetic in a config generator producing a negative value; unit confusion (bytes vs MB) leading to attempts to set a tiny/negative number.","solutions":["Set uploadSizeLimitMb to 0 to use the default limit, or a positive number of megabytes.","If you need unlimited uploads, omit the field rather than using a negative sentinel."],"exampleFix":"// before\n{ \"key\": \"STORAGE\", \"storageSetting\": { \"storageType\": \"LOCAL\", \"uploadSizeLimitMb\": -1 } }\n\n// after\n{ \"key\": \"STORAGE\", \"storageSetting\": { \"storageType\": \"LOCAL\", \"uploadSizeLimitMb\": 0 } }","handlingStrategy":"validation","validationCode":"if st.UploadSizeLimitMb < 0 {\n    return fmt.Errorf(\"uploadSizeLimitMb %d must be >= 0\", st.UploadSizeLimitMb)\n}","typeGuard":"func isValidUploadSizeLimitMb(v int32) bool { return v >= 0 }","tryCatchPattern":null,"preventionTips":["0 means 'use the default'; there is no unlimited sentinel, so never use -1.","Unit-check config generators: this field is megabytes, not bytes."],"tags":["configuration","validation","storage","startup"],"backgroundTag":null,"analyzedSha":"14d757ce1fb31c78590f374bc042f8dbedbc20d7","analyzedAt":"2026-08-15T09:27:36.538Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}