{"record":{"id":"5c8fffa44255ae07","repo":"apache/hadoop","slug":"no-transformation-given","errorCode":null,"errorMessage":"No transformation given.","messagePattern":"No transformation given\\.","errorType":"validation","errorClass":"NoSuchAlgorithmException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/OpensslCipher.java","lineNumber":158,"sourceCode":"  }\n  \n  /** Nested class for algorithm, mode and padding. */\n  private static class Transform {\n    final String alg;\n    final String mode;\n    final String padding;\n    \n    public Transform(String alg, String mode, String padding) {\n      this.alg = alg;\n      this.mode = mode;\n      this.padding = padding;\n    }\n  }\n  \n  private static Transform tokenizeTransformation(String transformation) \n      throws NoSuchAlgorithmException {\n    if (transformation == null) {\n      throw new NoSuchAlgorithmException(\"No transformation given.\");\n    }\n    \n    /*\n     * Array containing the components of a Cipher transformation:\n     * \n     * index 0: algorithm (e.g., AES)\n     * index 1: mode (e.g., CTR)\n     * index 2: padding (e.g., NoPadding)\n     */\n    String[] parts = new String[3];\n    int count = 0;\n    StringTokenizer parser = new StringTokenizer(transformation, \"/\");\n    while (parser.hasMoreTokens() && count < 3) {\n      parts[count++] = parser.nextToken().trim();\n    }\n    if (count != 3 || parser.hasMoreTokens()) {\n      throw new NoSuchAlgorithmException(\"Invalid transformation format: \" + \n          transformation);","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/OpensslCipher.java#L140-L176","documentation":"tokenizeTransformation() parses the cipher transformation string before the native cipher is created. A null transformation is rejected immediately with NoSuchAlgorithmException(\"No transformation given.\") rather than causing an NPE inside the parser.","triggerScenarios":"Passing a null transformation to OpensslCipher.getInstance() — typically because a configuration key holding the suite name was unset and returned null, or a variable was never initialized.","commonSituations":"Building the transformation from hadoop.security.crypto.cipher.suite when that key is absent and no default was applied; unit tests passing null; refactors that dropped the suite argument.","solutions":["Find why the transformation string is null — usually a missing configuration value — and supply it","Default to CipherSuite.AES_CTR_NOPADDING.getName() when the config key is unset","Null-check the transformation before calling getInstance and fail with a descriptive message"],"exampleFix":"// before\nString suite = conf.get(\"my.cipher.suite\"); // null if unset\nCipher c = OpensslCipher.getInstance(suite); // NoSuchAlgorithmException: No transformation given.\n\n// after\nString suite = conf.get(\"my.cipher.suite\", CipherSuite.AES_CTR_NOPADDING.getName());\nCipher c = OpensslCipher.getInstance(suite);","handlingStrategy":"validation","validationCode":"// Fail fast on missing config\nString suite = conf.get(\"hadoop.security.crypto.cipher.suite\");\nif (suite == null) {\n  suite = CipherSuite.AES_CTR_NOPADDING.getName();\n}\nCipher c = OpensslCipher.getInstance(suite);","typeGuard":"public String requireTransformation(String t) {\n  if (t == null || t.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"Cipher transformation must be set\");\n  }\n  return t;\n}","tryCatchPattern":"try {\n  cipher = OpensslCipher.getInstance(suite);\n} catch (NoSuchAlgorithmException e) {\n  throw new IllegalStateException(\"Cipher suite not configured or invalid: \" + suite, e);\n}","preventionTips":["Always provide a default when reading suite configuration","Assert non-null inputs at API boundaries instead of letting them reach the native layer","Log the effective suite at startup so null/missing values are visible immediately"],"tags":["crypto","openssl","null-argument","transformation"],"backgroundTag":"null-cipher-transformation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}