{"record":{"id":"f7ffc4de2b2f300e","repo":"usememos/memos","slug":"default-storage-is-not-configured","errorCode":null,"errorMessage":"default storage is not configured","messagePattern":"default storage is not configured","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/router/api/v1/attachment_service_storage.go","lineNumber":59,"sourceCode":"\t// In particular, never expose an expiring S3 presigned URL as attachment API\n\t// metadata because it can outlive a memo visibility change.\n\tif attachment.StorageType == storepb.AttachmentStorageType_EXTERNAL {\n\t\tattachmentMessage.ExternalLink = attachment.Reference\n\t}\n\n\treturn attachmentMessage\n}\n\n// SaveAttachmentBlob saves the blob of attachment based on the storage config.\nfunc SaveAttachmentBlob(ctx context.Context, profile *profile.Profile, stores *store.Store, create *store.Attachment) error {\n\tinstanceStorageSetting, err := stores.GetInstanceStorageSetting(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Failed to find instance storage setting\")\n\t}\n\n\tdefaultStorage := store.GetDefaultStorage(instanceStorageSetting)\n\tif defaultStorage == nil {\n\t\treturn errors.New(\"default storage is not configured\")\n\t}\n\n\tif defaultStorage.Type == storepb.StorageType_STORAGE_TYPE_LOCAL {\n\t\tfilepathTemplate := \"assets/{timestamp}_{uuid}_{filename}\"\n\t\tif instanceStorageSetting.FilepathTemplate != \"\" {\n\t\t\tfilepathTemplate = instanceStorageSetting.FilepathTemplate\n\t\t}\n\n\t\tinternalPath := filepathTemplate\n\t\tif !strings.Contains(internalPath, \"{filename}\") {\n\t\t\tinternalPath = filepath.Join(internalPath, \"{filename}\")\n\t\t}\n\t\tinternalPath = replaceFilenameWithPathTemplate(internalPath, create.Filename)\n\t\tinternalPath = filepath.ToSlash(internalPath)\n\n\t\t// Ensure the directory exists.\n\t\tosPath := filepath.FromSlash(internalPath)\n\t\tif !filepath.IsAbs(osPath) {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/server/router/api/v1/attachment_service_storage.go#L41-L77","documentation":"SaveAttachmentBlob could not find a default storage in the instance storage settings, so it has nowhere to write the attachment blob. Before this check it already failed loudly if the setting itself could not be read; nil default storage means the config was never initialized or was emptied.","triggerScenarios":"Uploading/creating an attachment on an instance whose storage settings lack a marked-default storage type; fresh installs where the storage setting row was not seeded; configs edited (via API or direct DB) to remove the default flag.","commonSituations":"Instance migrated or restored without system settings data; manual tampering with the `system_setting` storage row; partially completed setup where the admin skipped the storage step; version upgrades that changed the storage-setting schema shape.","solutions":["As admin, open Settings -> Storage and set/configure a default storage type (typically Local), then retry the upload","If settings look correct, inspect the instance storage setting in the DB (system_setting) for a malformed/missing value and re-save it from the UI","For programmatic setups, ensure the storage system setting is written before any attachment upload API is called"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Startup/health check: fail fast if storage is unconfigured before accepting uploads\nsetting, err := stores.GetInstanceStorageSetting(ctx)\nif err != nil { log.Fatal(err) }\nif store.GetDefaultStorage(setting) == nil {\n  log.Fatal(\"default storage is not configured; set it in Settings -> Storage before enabling uploads\")\n}","typeGuard":null,"tryCatchPattern":"// At upload time, translate to a clear admin-actionable error\nif err := SaveAttachmentBlob(ctx, profile, stores, create); err != nil {\n  if strings.Contains(err.Error(), \"default storage is not configured\") {\n    return status.Errorf(codes.FailedPrecondition, \"instance storage is not configured; an admin must set a default storage type\")\n  }\n  return err\n}","preventionTips":["Complete storage setup during initial instance installation","Include a storage-config check in deployment health checks","After DB restores or migrations, verify system settings rows before reopening uploads"],"tags":["storage","configuration","attachment"],"backgroundTag":null,"analyzedSha":"14d757ce1fb31c78590f374bc042f8dbedbc20d7","analyzedAt":"2026-08-15T09:27:36.538Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}