{"record":{"id":"d2d50053cbbb5b58","repo":"thanos-io/thanos","slug":"iter","errorCode":null,"errorMessage":"iter","messagePattern":"iter","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/tools_bucket.go","lineNumber":524,"sourceCode":"\t\t\t}\n\t\t\tprintBlock = func(m *metadata.Meta) error {\n\t\t\t\tif err := tmpl.Execute(os.Stdout, &m); err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"execute template\")\n\t\t\t\t}\n\t\t\t\tfmt.Fprintln(os.Stdout, \"\")\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\n\t\tmetas, _, err := fetcher.Fetch(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, meta := range metas {\n\t\t\tobjects++\n\t\t\tif err := printBlock(meta); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"iter\")\n\t\t\t}\n\t\t}\n\t\tlevel.Info(logger).Log(\"msg\", \"ls done\", \"objects\", objects)\n\t\treturn nil\n\t})\n}\n\nfunc registerBucketInspect(app extkingpin.AppClause, objStoreConfig *extflag.PathOrContent) {\n\tcmd := app.Command(\"inspect\", \"Inspect all blocks in the bucket in detailed, table-like way.\")\n\n\ttbc := &bucketInspectConfig{}\n\ttbc.registerBucketInspectFlag(cmd)\n\n\toutput := cmd.Flag(\"output\", \"Output format for result. Currently supports table, csv, tsv.\").Default(\"table\").Enum(outputTypes...)\n\n\tcmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error {\n\n\t\t// Parse selector.","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/tools_bucket.go#L506-L542","documentation":"In the bucket `ls` command, after fetching metadata for every object, the code iterates over the metas and calls printBlock(meta) for each; any error from that callback (which is itself the 'execute template' wrap of tmpl.Execute) is re-wrapped as 'iter'. So this error means the per-object printing step failed while iterating, almost always due to a bad --format template.","triggerScenarios":"Running `thanos tools bucket ls <bucket> --format '<template>'` where the template fails to execute against one of the listed metadata.Meta values (nonexistent field, nil pointer dereference in template) — cmd/thanos/tools_bucket.go:524.","commonSituations":"Same as the template execution failure: templates copied from docs for a different struct, fields renamed after Thanos upgrades, or accessing .Thana on blocks whose meta lacks it.","solutions":["Fix the --format template so it only references fields present on metadata.Meta.","Add {{if}} nil-guards around optional pointer fields in the template.","If the wrapped inner error mentions a field, compare against the metadata.Meta struct definition and correct it.","Test the template against a single block ID before running on the whole bucket."],"exampleFix":"// before\nthanos tools bucket ls bkt --format '{{.MinTime }}'\n// after\nthanos tools bucket ls bkt --format '{{.MinTime}}'  // ensure field exists on metadata.Meta; otherwise use .MinMaxTime as defined","handlingStrategy":"try-catch","validationCode":"if _, err := template.New(\"\").Parse(format); err != nil {\n    return fmt.Errorf(\"invalid --format: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := runLs(...)\nif err != nil && strings.Contains(err.Error(), \"iter\") {\n    // retry with the default template\n    return runLsWithFormat(\"{{.ULID}}\")\n}","preventionTips":["Keep --format templates minimal and version-tested","Validate the template parses before running on large buckets","Reuse documented example formats instead of hand-written ones","Pin Thanos version when scripting, since meta fields can change"],"tags":["go-template","cli","iteration"],"backgroundTag":"invalid-argument-value","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}