{"record":{"id":"3cda34538dd1368e","repo":"apache/maven","slug":"unsupported-algorithm","errorCode":null,"errorMessage":"unsupported algorithm","messagePattern":"unsupported algorithm","errorType":"exception","errorClass":"ChecksumAlgorithmServiceException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultChecksumAlgorithmService.java","lineNumber":70,"sourceCode":"    public DefaultChecksumAlgorithmService(ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector) {\n        this.checksumAlgorithmFactorySelector =\n                requireNonNull(checksumAlgorithmFactorySelector, \"checksumAlgorithmFactorySelector\");\n    }\n\n    @Override\n    public Collection<String> getChecksumAlgorithmNames() {\n        return checksumAlgorithmFactorySelector.getChecksumAlgorithmFactories().stream()\n                .map(ChecksumAlgorithmFactory::getName)\n                .collect(Collectors.toList());\n    }\n\n    @Override\n    public ChecksumAlgorithm select(String algorithmName) {\n        requireNonNull(algorithmName, \"algorithmName\");\n        try {\n            return new DefaultChecksumAlgorithm(checksumAlgorithmFactorySelector.select(algorithmName));\n        } catch (IllegalArgumentException e) {\n            throw new ChecksumAlgorithmServiceException(\"unsupported algorithm\", e);\n        }\n    }\n\n    @Override\n    public Collection<ChecksumAlgorithm> select(Collection<String> algorithmNames) {\n        requireNonNull(algorithmNames, \"algorithmNames\");\n        try {\n            return checksumAlgorithmFactorySelector.selectList(new ArrayList<>(algorithmNames)).stream()\n                    .map(DefaultChecksumAlgorithm::new)\n                    .collect(Collectors.toList());\n        } catch (IllegalArgumentException e) {\n            throw new ChecksumAlgorithmServiceException(\"unsupported algorithm\", e);\n        }\n    }\n\n    @Override\n    public Map<ChecksumAlgorithm, String> calculate(byte[] data, Collection<ChecksumAlgorithm> algorithms) {\n        requireNonNull(data, \"data\");","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultChecksumAlgorithmService.java#L52-L88","documentation":"DefaultChecksumAlgorithmService.select(algorithmName) delegates to the resolver's ChecksumAlgorithmFactorySelector, which only knows factories registered in the container (by default SHA-1, SHA-256, SHA-512 in Maven's wiring). An unknown or misspelled name throws ChecksumAlgorithmServiceException('unsupported algorithm') with the selector's IllegalArgumentException as cause. Algorithm names are case-sensitive as registered (e.g. 'SHA-256', not 'sha256').","triggerScenarios":"Calling checksumService.select('MD5') when no MD5 factory is registered, select('sha-256') (lowercase), or select('SHA-512') in a container wiring where the SHA-512 factory was not installed.","commonSituations":"Hardcoding 'MD5' from older tooling; copy-pasting lowercase hex-style names; embedding Resolver in a standalone app and registering only some checksum factories; configuration files referencing checksum algorithms by wrong casing.","solutions":["Use a name returned by checksumService.getChecksumAlgorithmNames() (typically 'SHA-1', 'SHA-256', 'SHA-512')","Validate user-supplied names against getChecksumAlgorithmNames() before selecting","If MD5 is genuinely required, register an Md5ChecksumAlgorithmFactory-based component in your container wiring"],"exampleFix":"// before\nChecksumAlgorithm alg = service.select('sha-256'); // throws\n\n// after\nChecksumAlgorithm alg = service.select(\n        service.getChecksumAlgorithmNames().stream()\n                .filter(n -> n.equalsIgnoreCase('sha-256'))\n                .findFirst()\n                .orElseThrow(() -> new IllegalArgumentException('unsupported checksum algorithm')));","handlingStrategy":"validation","validationCode":"Set<String> supported = Set.copyOf(service.getChecksumAlgorithmNames());\nif (!supported.contains(algorithmName)) {\n    throw new IllegalArgumentException('Unsupported checksum algorithm: ' + algorithmName + '; supported: ' + supported);\n}","typeGuard":"static boolean isSupportedAlgorithm(ChecksumAlgorithmService s, String name) { return s.getChecksumAlgorithmNames().contains(name); }","tryCatchPattern":null,"preventionTips":["Offer only names from getChecksumAlgorithmNames() in configuration UIs/docs","Use exact casing (SHA-256, SHA-512, SHA-1)","Do not assume MD5 is registered; check the wiring of your container"],"tags":["maven","checksum","validation"],"backgroundTag":"unsupported-checksum-algorithm","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}