{"record":{"id":"4cb8c175d8b9fdc9","repo":"thanos-io/thanos","slug":"unexpected-meta-file-thanos-section-version-d","errorCode":null,"errorMessage":"unexpected meta file Thanos section version %d","messagePattern":"unexpected meta file Thanos section version (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/metadata/meta.go","lineNumber":291,"sourceCode":"\tdefer runutil.ExhaustCloseWithErrCapture(&err, rc, \"close meta JSON\")\n\n\tvar m Meta\n\tif err = json.NewDecoder(rc).Decode(&m); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif m.Version != TSDBVersion1 {\n\t\treturn nil, errors.Errorf(\"unexpected meta file version %d\", m.Version)\n\t}\n\n\tversion := m.Thanos.Version\n\tif version == 0 {\n\t\t// For compatibility.\n\t\tversion = ThanosVersion1\n\t}\n\n\tif version != ThanosVersion1 {\n\t\treturn nil, errors.Errorf(\"unexpected meta file Thanos section version %d\", m.Version)\n\t}\n\n\tif m.Thanos.Labels == nil {\n\t\t// To avoid extra nil checks, allocate map here if empty.\n\t\tm.Thanos.Labels = make(map[string]string)\n\t}\n\treturn &m, nil\n}\n","sourceCodeStart":273,"sourceCodeEnd":300,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/metadata/meta.go#L273-L300","documentation":"Read rejects meta.json files whose thanos section version is not ThanosVersion1 (1). Note the message incorrectly reports m.Version (the TSDB version) instead of the Thanos version. After defaulting version 0 to ThanosVersion1 for backwards compatibility, any other value is rejected.","triggerScenarios":"Calling Read on a meta.json whose \"thanos.version\" field is set to a value other than 0 or 1 (e.g. 2) — typically a block written by a newer Thanos with a bumped Thanos meta format.","commonSituations":"Older Thanos binary reading blocks produced by a newer Thanos that bumped thanos.version; hand-edited thanos section; corrupted meta.json.","solutions":["Inspect meta.json's \"thanos\".\"version\" field; only 0/1 are accepted by this reader.","Upgrade Thanos to a version matching the block's thanos meta version.","Rewrite the block's meta.json with a compatible writer (e.g. re-upload from source).","If hand-edited, restore thanos.version to 1 (or remove it for compatibility default)."],"exampleFix":"// before (meta.json)\n{\"version\":1,\"thanos\":{\"version\":2,...}}\n// after\n{\"version\":1,\"thanos\":{\"version\":1,...}}","handlingStrategy":"validation","validationCode":"var raw struct{ Thanos struct{ Version int `json:\"version\"` } `json:\"thanos\"` }\nb, _ := os.ReadFile(filepath.Join(bdir, \"meta.json\"))\nif json.Unmarshal(b, &raw) == nil {\n    if v := raw.Thanos.Version; v != 0 && v != 1 {\n        return fmt.Errorf(\"unsupported thanos meta version %d in %s\", v, bdir)\n    }\n}","typeGuard":"func isThanosMetaV1(raw []byte) bool {\n    var m struct{ Thanos struct{ Version int `json:\"version\"` } `json:\"thanos\"` }\n    return json.Unmarshal(raw, &m) == nil && (m.Thanos.Version == 0 || m.Thanos.Version == 1)\n}","tryCatchPattern":"m, err := metadata.ReadFromDir(ctx, bdir)\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected meta file Thanos section version\") {\n        logger.Log(\"msg\", \"block written by newer Thanos; upgrade required\", \"dir\", bdir)\n        return nil\n    }\n    return err\n}","preventionTips":["Run the same or newer Thanos version on readers as on writers.","Check the thanos.version field when importing blocks from another deployment.","Plan upgrades so blocks written after a meta format bump are never read by old binaries."],"tags":["go","metadata","version-mismatch","validation"],"backgroundTag":"invalid-enum-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"}