{"record":{"id":"c25ad9db02f47e87","repo":"sebastianbergmann/phpunit","slug":"cannot-read-baseline-s-version-d-is-not-support","errorCode":null,"errorMessage":"Cannot read baseline %s, version %d is not supported","messagePattern":"Cannot read baseline (.+?), version (.+?) is not supported","errorType":"exception","errorClass":"CannotLoadBaselineException","httpStatus":null,"severity":"error","filePath":"src/Runner/Baseline/Reader.php","lineNumber":67,"sourceCode":"            $document = (new XmlLoader)->loadFile($baselineFile);\n        } catch (XmlException $e) {\n            throw new CannotLoadBaselineException(\n                sprintf(\n                    'Cannot read baseline %s: %s',\n                    $baselineFile,\n                    trim($e->getMessage()),\n                ),\n            );\n        }\n\n        $documentElement = $document->documentElement;\n\n        assert($documentElement !== null);\n\n        $version = (int) $documentElement->getAttribute('version');\n\n        if ($version !== Baseline::VERSION) {\n            throw new CannotLoadBaselineException(\n                sprintf(\n                    'Cannot read baseline %s, version %d is not supported',\n                    $baselineFile,\n                    $version,\n                ),\n            );\n        }\n\n        $baseline             = new Baseline;\n        $resolvedBaselineFile = realpath($baselineFile);\n\n        assert($resolvedBaselineFile !== false);\n\n        $baselineDirectory = dirname($resolvedBaselineFile);\n        $xpath             = new DOMXPath($document);\n\n        $fileElements = $xpath->query('file');\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/Runner/Baseline/Reader.php#L49-L85","documentation":"The baseline document's root element carries a version attribute (the Writer records Baseline::VERSION, currently 1) and Reader::read() refuses any other value because the schema cannot be trusted. The message shows the file and the offending version; a missing version attribute parses as '' and (int) casts to 0, which is also rejected.","triggerScenarios":"Baseline generated by a different PHPUnit version whose Baseline::VERSION differs; hand-written baseline without version=\"1\" on the root; a baseline produced by a newer schema version then consumed by an older PHPUnit.","commonSituations":"Upgrading or downgrading PHPUnit while reusing an old baseline file; teams sharing one baseline across PHPUnit versions; crafting a baseline by hand from a template that omits the attribute.","solutions":["Regenerate the baseline with the PHPUnit version you now run: vendor/bin/phpunit --generate-baseline=<path>.","If hand-authoring, ensure the root element is <files version=\"1\"> (the value of Baseline::VERSION in your build).","Do not share a baseline across PHPUnit versions with differing schema versions; regenerate after each upgrade."],"exampleFix":"<!-- before -->\n<files>\n  <file path=\"src/Foo.php\"><line number=\"1\" hash=\"...\"/></file>\n</files>\n\n<!-- after -->\n<files version=\"1\">\n  <file path=\"src/Foo.php\"><line number=\"1\" hash=\"...\"/></file>\n</files>","handlingStrategy":"validation","validationCode":"// Check the schema version before loading\n$doc = new DOMDocument();\n$doc->load($baselinePath);\n$version = (int) ($doc->documentElement->getAttribute('version') ?? '0');\nif ($version !== 1) { // Baseline::VERSION of the PHPUnit build in use\n    fwrite(STDERR, \"Baseline version {$version} not supported; regenerate it\\n\");\n    exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate the baseline after every PHPUnit upgrade.","Do not hand-write baselines; the Writer emits the exact schema PHPUnit expects.","Pin or align PHPUnit versions across environments that share a baseline."],"tags":["phpunit","php","baseline","version-mismatch","xml"],"backgroundTag":"baseline-version-mismatch","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}