{"record":{"id":"631e5bdbf6da5e49","repo":"quarkusio/quarkus","slug":"failed-to-load-platform-catalog-from-jsonfile","errorCode":null,"errorMessage":"Failed to load platform catalog from ${jsonFile}","messagePattern":"Failed to load platform catalog from (.+?)","errorType":"exception","errorClass":"RegistryResolutionException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/client/maven/MavenPlatformsResolver.java","lineNumber":51,"sourceCode":"    @Override\n    public PlatformCatalog.Mutable resolvePlatforms(String quarkusVersion) throws RegistryResolutionException {\n        final ArtifactCoords baseCoords = config.getArtifact();\n        final Artifact catalogArtifact = new DefaultArtifact(baseCoords.getGroupId(), baseCoords.getArtifactId(),\n                quarkusVersion, baseCoords.getType(), baseCoords.getVersion());\n        log.debug(\"Resolving platform catalog %s\", catalogArtifact);\n        final ArtifactResult artifactResult;\n        try {\n            artifactResult = artifactResolver.resolveArtifact(catalogArtifact);\n        } catch (Exception e) {\n            log.debug(\"Failed to resolve platform catalog %s\", catalogArtifact);\n            return null;\n        }\n        final Path jsonFile = artifactResult.getArtifact().getFile().toPath();\n        final PlatformCatalog.Mutable catalog;\n        try {\n            catalog = PlatformCatalog.mutableFromFile(jsonFile);\n        } catch (IOException e) {\n            throw new RegistryResolutionException(\n                    \"Failed to load platform catalog from \" + jsonFile, e);\n        }\n\n        try {\n            final Metadata mavenMetadata = artifactResolver.resolveMetadata(artifactResult);\n            if (mavenMetadata != null) {\n                final String lastUpdated = mavenMetadata.getVersioning() == null ? null\n                        : mavenMetadata.getVersioning().getLastUpdated();\n                if (lastUpdated != null) {\n                    /*\n                     * This is how it can be parsed\n                     * java.util.TimeZone timezone = java.util.TimeZone.getTimeZone(\"UTC\");\n                     * java.text.DateFormat fmt = new java.text.SimpleDateFormat(\"yyyyMMddHHmmss\");\n                     * fmt.setTimeZone(timezone);\n                     * final Date date = fmt.parse(lastUpdated);\n                     */\n                    catalog.setMetadata(Constants.LAST_UPDATED, lastUpdated);\n                }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/client/maven/MavenPlatformsResolver.java#L33-L69","documentation":"Thrown by MavenPlatformsResolver.resolvePlatforms when the resolved platform catalog JSON artifact cannot be read or parsed. The resolver located and downloaded the platform-catalog artifact, then PlatformCatalog.mutableFromFile(jsonFile) failed with an IOException while opening or deserializing the file. The underlying IOException is kept as the cause.","triggerScenarios":"Calling resolvePlatforms where the platform-catalog artifact exists locally or was fetched but its JSON file is corrupt, truncated, empty, not valid Quarkus platform-catalog JSON, or cannot be opened due to filesystem permissions.","commonSituations":"Interrupted downloads leaving partial files in ~/.m2/repository; a repository manager serving cached error pages instead of the JSON artifact; a platform catalog generated by a newer/incompatible registry JSON schema; read-only or permission-restricted CI cache volumes.","solutions":["Delete the corrupt artifact from the local Maven repository and re-run to force re-download (mvn -U or clear ~/.m2/repository/<platform-catalog-path>).","Inspect the file at the printed jsonFile path with jq to confirm whether it is valid JSON or an error page; fix the repository/mirror if so.","Retry with a fresh local repository (-Dmaven.repo.local=<dir>) to bypass cache corruption.","Align the registry-client/Quarkus version with the platform catalog schema version in use.","Check read permissions on the local repository path."],"exampleFix":"// before: failing against a corrupt cached catalog\nquarkus platform list\n// after: purge and re-resolve the catalog\nrm -rf ~/.m2/repository/io/quarkus/platform && mvn -U quarkus:platform-list","handlingStrategy":"try-catch","validationCode":"Path jsonFile = Path.of(\"...platform-catalog.json\");\nif (!Files.isRegularFile(jsonFile) || !Files.isReadable(jsonFile)) {\n    throw new IllegalStateException(\"Platform catalog not readable: \" + jsonFile);\n}\nif (Files.size(jsonFile) == 0) {\n    throw new IllegalStateException(\"Platform catalog is empty (corrupt download?): \" + jsonFile);\n}\n// sanity: first non-whitespace char should be '{'\ntry (var r = Files.newBufferedReader(jsonFile)) {\n    int c; while ((c = r.read()) != -1 && Character.isWhitespace(c));\n    if (c != '{') throw new IllegalStateException(\"Not JSON content\");\n}","typeGuard":"static boolean looksLikeValidCatalogFile(Path p) {\n    try {\n        if (!Files.isRegularFile(p) || !Files.isReadable(p) || Files.size(p) == 0) return false;\n        try (var r = Files.newBufferedReader(p)) {\n            int c; do { c = r.read(); } while (c != -1 && Character.isWhitespace(c));\n            return c == '{';\n        }\n    } catch (IOException e) { return false; }\n}","tryCatchPattern":"try {\n    PlatformCatalog catalog = resolver.resolvePlatforms();\n} catch (RegistryResolutionException e) {\n    if (e.getMessage().startsWith(\"Failed to load platform catalog from\")) {\n        // purge corrupt artifact from local repo and retry once\n        purgeFromLocalRepo(e.getMessage().replace(\"Failed to load platform catalog from \", \"\"));\n        catalog = resolver.resolvePlatforms();\n    } else throw e;\n}","preventionTips":["Use -U / clean local repo after interrupted builds to evict truncated downloads.","Ensure your repository manager caches JSON artifacts correctly and does not inject error pages.","Keep registry-client version compatible with the platform catalog JSON schema.","Run builds with a user-owned, writable local Maven repository.","Monitor CI shared caches for permission or corruption issues."],"tags":["maven","json-parsing","registry","cache-corruption"],"backgroundTag":"json-parse-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}