{"record":{"id":"651115192e7cd48b","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-set-metadata-for-q-at-s-w","errorCode":null,"errorMessage":"cannot set metadata for %q at %s: %w","messagePattern":"cannot set metadata for %q at (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/backup/azremote/azblob.go","lineNumber":249,"sourceCode":"\t\t}\n\n\t\t// After the copy will be finished status will be changed to success/failed/aborted\n\t\t// Ref: https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-properties#response-headers - x-ms-copy-status\n\t\tif *r.CopyStatus != blob.CopyStatusTypePending {\n\t\t\tcopyStatus = r.CopyStatus\n\t\t\tcopyStatusDescription = r.CopyStatusDescription\n\t\t\tbreak\n\t\t}\n\n\t\tselect {\n\t\tcase <-fs.ctx.Done():\n\t\t\treturn fs.ctx.Err()\n\t\tcase <-time.After(5 * time.Second):\n\t\t\t// Continue checking\n\t\t}\n\t}\n\tif err := fs.maybeSetMetadata(dbc); err != nil {\n\t\treturn fmt.Errorf(\"cannot set metadata for %q at %s: %w\", p.Path, fs, err)\n\t}\n\n\tif *copyStatus != blob.CopyStatusTypeSuccess {\n\t\treturn fmt.Errorf(\"copy of %q from %s to %s failed: expected status %q, received %q (description: %q)\", p.Path, src, fs, blob.CopyStatusTypeSuccess, *copyStatus, *copyStatusDescription)\n\t}\n\n\treturn nil\n}\n\n// DownloadPart downloads part p from fs to w.\nfunc (fs *FS) DownloadPart(p common.Part, w io.Writer) error {\n\tbc := fs.clientForPart(p)\n\n\tr, err := bc.DownloadStream(fs.ctx, &blob.DownloadStreamOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot open reader for %q at %s (remote path %q): %w\", p.Path, fs, bc.URL(), err)\n\t}\n","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/backup/azremote/azblob.go#L231-L267","documentation":"Once the async copy finishes, CopyPart calls maybeSetMetadata on the destination blob. This error wraps a failure of that metadata write after the copy completed, meaning the data is copied but metadata was not applied.","triggerScenarios":"fs.maybeSetMetadata(dbc) returns an error after the polling loop observed a terminal copy status: transient network failure, authorization/permission issue, or context cancellation during SetMetadata.","commonSituations":"SAS tokens without metadata write permission; expired tokens on long copies; transient Azure Storage 5xx responses; destination container permissions changed mid-operation.","solutions":["Inspect the wrapped error's HTTP status: 403 means the credential lacks metadata write permission.","Retry CopyPart — the copy-from-url is idempotent per part.","Refresh credentials or grant Storage Blob Data Contributor on the destination.","Confirm the destination container allows user metadata updates."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := fs.CopyPart(src, part); err != nil && strings.Contains(err.Error(), \"cannot set metadata\") {\n    // copy finished but metadata failed; safe to retry CopyPart (idempotent)\n}","preventionTips":["Grant metadata write permission on destination credentials","Keep context alive long enough for post-copy metadata calls","Retry on transient metadata failures after copy completes","Verify SAS token includes the metadata write permission"],"tags":["azure","azure-blob","metadata","async-copy","permissions"],"backgroundTag":"blob-metadata-write-failed","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}