{"record":{"id":"001b84128bb6038c","repo":"benbjohnson/litestream","slug":"failed-to-list-all-objects-w","errorCode":null,"errorMessage":"failed to list all objects: %w","messagePattern":"failed to list all objects: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nats/replica_client.go","lineNumber":470,"sourceCode":"\t}\n\n\treturn nil\n}\n\n// DeleteAll deletes all files in the object store.\nfunc (c *ReplicaClient) DeleteAll(ctx context.Context) error {\n\tif err := c.Init(ctx); err != nil {\n\t\treturn err\n\t}\n\n\t// List all objects in the bucket\n\tobjectList, err := c.objectStore.List(ctx)\n\tif err != nil {\n\t\t// NATS returns \"no objects found\" when bucket is empty, treat as empty list\n\t\tif strings.Contains(err.Error(), \"no objects found\") {\n\t\t\tobjectList = nil // Empty list, nothing to delete\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"failed to list all objects: %w\", err)\n\t\t}\n\t}\n\n\tfor _, objInfo := range objectList {\n\t\tif err := c.objectStore.Delete(ctx, objInfo.Name); err != nil {\n\t\t\tif !isNotFoundError(err) {\n\t\t\t\treturn fmt.Errorf(\"failed to delete object %s: %w\", objInfo.Name, err)\n\t\t\t}\n\t\t}\n\t\tinternal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, \"DELETE\").Inc()\n\t}\n\n\treturn nil\n}\n\n// isNotFoundError checks if the error is a \"not found\" error.\nfunc isNotFoundError(err error) bool {\n\treturn err != nil && (errors.Is(err, jetstream.ErrObjectNotFound) || strings.Contains(err.Error(), \"not found\"))","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/nats/replica_client.go#L452-L488","documentation":"DeleteAll's initial List of the NATS object store failed with an error other than the benign 'no objects found' (empty bucket) case. Connection, auth, or JetStream state problem prevented enumeration for deletion.","triggerScenarios":"Thrown at nats/replica_client.go:470 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check NATS connectivity and credentials","Verify the bucket/stream exists and is not in an error state"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}