{"record":{"id":"a9089d3aa5d82ae6","repo":"thanos-io/thanos","slug":"unexpected-meta-file-s-version-d","errorCode":null,"errorMessage":"unexpected meta file: %s version: %d","messagePattern":"unexpected meta file: (.+?) version: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/fetcher.go","lineNumber":500,"sourceCode":"\t}\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"get meta file: %v\", metaFile)\n\t}\n\n\tdefer runutil.CloseWithLogOnErr(f.logger, r, \"close bkt meta get\")\n\n\tmetaContent, err := io.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"read meta file: %v\", metaFile)\n\t}\n\n\tm := &metadata.Meta{}\n\tif err := json.Unmarshal(metaContent, m); err != nil {\n\t\treturn nil, errors.Wrapf(ErrorSyncMetaCorrupted, \"meta.json %v unmarshal: %v\", metaFile, err)\n\t}\n\n\tif m.Version != metadata.TSDBVersion1 {\n\t\treturn nil, errors.Errorf(\"unexpected meta file: %s version: %d\", metaFile, m.Version)\n\t}\n\n\t// Best effort cache in local dir.\n\tif f.cacheDir != \"\" {\n\t\tif err := os.MkdirAll(cachedBlockDir, os.ModePerm); err != nil {\n\t\t\tlevel.Warn(f.logger).Log(\"msg\", \"best effort mkdir of the meta.json block dir failed; ignoring\", \"dir\", cachedBlockDir, \"err\", err)\n\t\t}\n\n\t\tif err := m.WriteToDir(f.logger, cachedBlockDir); err != nil {\n\t\t\tlevel.Warn(f.logger).Log(\"msg\", \"best effort save of the meta.json to local dir failed; ignoring\", \"dir\", cachedBlockDir, \"err\", err)\n\t\t}\n\t}\n\treturn m, nil\n}\n\ntype response struct {\n\tmetas              map[ulid.ULID]*metadata.Meta\n\tpartial            map[ulid.ULID]error","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/fetcher.go#L482-L518","documentation":"After unmarshaling meta.json successfully, loadMeta validates that metadata.Meta.Version equals metadata.TSDBVersion1. If the version field differs, it throws errors.Errorf with this message and the block is rejected during sync. This guards against blocks written by incompatible TSDB meta.json schema versions.","triggerScenarios":"Syncing (fetchMetadata) a block whose meta.json has version != 1 — e.g. a meta.json with \"version\": 2 or higher, or version 0/missing after hand-editing.","commonSituations":"Blocks produced by newer Prometheus/Thanos with an upgraded meta.json schema being consumed by an older Thanos; manually rewritten meta.json omitting or zeroing the version field; forged/hand-crafted test blocks.","solutions":["Check the block's meta.json \"version\" field; ensure it is 1 (TSDBVersion1).","Upgrade Thanos to a version that supports the block's meta.json version if it was produced by newer tooling.","Re-create/re-upload the block from a compatible Prometheus/Compactor version rather than editing version by hand.","Remove the incompatible block from the bucket if it is not needed."],"exampleFix":"// before: meta.json with wrong version\n{\"ulid\":\"01ARZ3NDEKTSV4RRFFQ69G5FAV\",\"version\":2}\n// after: re-upload block produced with supported schema\n{\"ulid\":\"01ARZ3NDEKTSV4RRFFQ69G5FAV\",\"version\":1}","handlingStrategy":"validation","validationCode":"var meta struct {\n    Version int `json:\"version\"`\n}\nif err := json.Unmarshal(metaContent, &meta); err != nil || meta.Version != 1 {\n    // reject before sync: block meta.json version unsupported\n}","typeGuard":"func isVersionMismatchError(err error) bool {\n    return strings.Contains(err.Error(), \"unexpected meta file\")\n}","tryCatchPattern":"if _, err := fetcher.FetchMetadata(ctx, filtered); err != nil {\n    if strings.Contains(err.Error(), \"unexpected meta file\") {\n        // identify the block, verify its meta.json version, upgrade Thanos or drop the block\n    }\n}","preventionTips":["Run a single Thanos version across the fleet that supports all block versions in the bucket.","Before downgrading Thanos, check the highest meta.json version written by the newer version.","Do not forge or manually rewrite meta.json version fields.","Pin Compactor/Prometheus versions compatible with your Thanos reader."],"tags":["object-storage","versioning","blocks","compatibility"],"backgroundTag":"incompatible-source-type","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"}