{"record":{"id":"d545227a9051c7d6","repo":"benbjohnson/litestream","slug":"failed-to-list-objects-w","errorCode":null,"errorMessage":"failed to list objects: %w","messagePattern":"failed to list objects: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nats/replica_client.go","lineNumber":298,"sourceCode":"}\n\n// LTXFiles returns an iterator of all LTX files on the replica for a given level.\n// NATS always uses accurate timestamps from headers since they're included in LIST operations at zero cost.\n// The useMetadata parameter is ignored.\nfunc (c *ReplicaClient) LTXFiles(ctx context.Context, level int, seek ltx.TXID, useMetadata bool) (ltx.FileIterator, error) {\n\tif err := c.Init(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// List all objects in the store\n\tinternal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, \"LIST\").Inc()\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\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"failed to list objects: %w\", err)\n\t\t}\n\t}\n\n\tprefix := litestream.LTXLevelDir(c.Path, level) + \"/\"\n\tfileInfos := make([]*ltx.FileInfo, 0, len(objectList))\n\n\tfor _, objInfo := range objectList {\n\t\t// Filter by level prefix\n\t\tif !strings.HasPrefix(objInfo.Name, prefix) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfileLevel, minTXID, maxTXID, err := c.parseLTXPath(objInfo.Name)\n\t\tif err != nil {\n\t\t\tcontinue // Skip invalid paths\n\t\t}\n\n\t\tif fileLevel != level {","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/nats/replica_client.go#L280-L316","documentation":"Wraps objectStore.List failure in the NATS replica client's LTXFiles. Fires when listing all objects in the NATS object store fails (connection or server error), so the LTX file iterator cannot be built; distinct from os.ErrNotExist handling.","triggerScenarios":"Thrown at nats/replica_client.go:298 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the NATS bucket exists and credentials allow list access","Check NATS server connectivity and JetStream enablement","Retry; transient NATS errors are retried on the next sync"],"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-14T00:17:10.932Z"}