{"record":{"id":"25f58e075bc7d82e","repo":"zitadel/zitadel","slug":"upload-failed-w","errorCode":null,"errorMessage":"upload failed: %w","messagePattern":"upload failed: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/api/assets/asset.go","lineNumber":200,"sourceCode":"\t\t}\n\n\t\tresourceOwner := uploader.ResourceOwner(authz.GetInstance(ctx), ctxData)\n\t\tobjectName, err := uploader.ObjectName(ctxData)\n\t\tif err != nil {\n\t\t\ts.ErrorHandler()(w, r, fmt.Errorf(\"upload failed: %v\", err), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tuploadInfo := &command.AssetUpload{\n\t\t\tResourceOwner: resourceOwner,\n\t\t\tObjectName:    objectName,\n\t\t\tContentType:   mimeType.String(),\n\t\t\tObjectType:    uploader.ObjectType(),\n\t\t\tFile:          file,\n\t\t\tSize:          size,\n\t\t}\n\t\terr = uploader.UploadAsset(ctx, ctxData.OrgID, uploadInfo, s.Commands())\n\t\tif err != nil {\n\t\t\ts.ErrorHandler()(w, r, fmt.Errorf(\"upload failed: %w\", err), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc DownloadHandleFunc(s AssetsService, downloader Downloader) func(http.ResponseWriter, *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tif s.Storage() == nil {\n\t\t\treturn\n\t\t}\n\t\tctx := r.Context()\n\t\townerPath := mux.Vars(r)[\"owner\"]\n\t\tresourceOwner := downloader.ResourceOwner(ctx, ownerPath)\n\t\tpath := \"\"\n\t\tif ownerPath != \"\" {\n\t\t\tsplitPath := strings.Split(r.RequestURI, ownerPath+\"/\")\n\t\t\tif len(splitPath) < 2 {\n\t\t\t\ts.ErrorHandler()(w, r, fmt.Errorf(\"invalid request URI format: %v\", r.RequestURI), http.StatusNotFound)","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/zitadel/zitadel/blob/13948f2bcd6f257794dbd6d342c2ac30bc88fe54/internal/api/assets/asset.go#L182-L218","documentation":"The actual storage upload (uploader.UploadAsset, which invokes the command layer to persist the asset to S3/GCS/db storage) failed; the handler wraps the underlying storage error as 500 'upload failed'.","triggerScenarios":"UploadAsset returns an error from the storage backend or the event/command layer: bucket missing, credentials invalid, network failure to S3/GCS, or command-side validation (e.g. asset type not allowed for the resource owner).","commonSituations":"Misconfigured S3 endpoint/keys in the storage config; MinIO not reachable; permission denied writing to the bucket; database connectivity issues during the command commit.","solutions":["Inspect server logs for the wrapped inner error from UploadAsset","Verify storage backend config (endpoint, bucket, access keys) and that the bucket exists and is writable","Test database/storage connectivity and re-upload"],"exampleFix":"// before\nStorage:\n  Type: s3\n  Endpoint: https://minio.internal:9000\n  Bucket: zitadel-assets # bucket does not exist\n// after\n# create the bucket first, then:\nStorage:\n  Type: s3\n  Endpoint: https://minio.internal:9000\n  Bucket: zitadel-assets\n  AccessKeyID: <key>\n  SecretAccessKey: <secret>","handlingStrategy":"retry","validationCode":"// preflight: verify storage backend reachability/credentials before large uploads\nawait fetch(`${storageHealthEndpoint}`); // or test-list the configured bucket in ops tooling","typeGuard":null,"tryCatchPattern":"try {\n  await uploadToOrgAssets(orgId, file);\n} catch (e) {\n  if (e.status === 500 && e.message.includes(\"upload failed\")) {\n    await backoff(3, () => uploadToOrgAssets(orgId, file)); // safe to retry idempotent uploads\n  }\n}","preventionTips":["Monitor S3/GCS/db availability; upload failures are usually infrastructure","Verify bucket credentials and writability after every storage config change","Keep uploads idempotent so retry after transient storage errors is safe"],"tags":["storage","assets","upload"],"backgroundTag":"upload-failed","analyzedSha":"13948f2bcd6f257794dbd6d342c2ac30bc88fe54","analyzedAt":"2026-09-06T10:16:19.814Z","contentChangedAt":"2026-09-06T10:16:19.814Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}