{"record":{"id":"13bd7b5c7b15eed7","repo":"apache/beam","slug":"secret-string-must-contain-a-valid-type-parameter","errorCode":null,"errorMessage":"Secret string must contain a valid type parameter","messagePattern":"Secret string must contain a valid type parameter","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/Secret.java","lineNumber":217,"sourceCode":"   * 'type:&lt;secret_type&gt;;&lt;secret_param&gt;:&lt;value&gt;'\n   *\n   * <p>For example, 'type:GcpSecret;version_name:my_secret/versions/latest' would return a\n   * GcpSecret initialized with 'my_secret/versions/latest'.\n   */\n  public static Secret parseSecretOption(String secretOption) {\n    if (secretOption == null) {\n      throw new IllegalArgumentException(\"Secret option string cannot be null\");\n    }\n    Map<String, String> paramMap = new HashMap<>();\n    for (String param : secretOption.split(\";\", -1)) {\n      String[] parts = param.split(\":\", 2);\n      if (parts.length == 2) {\n        paramMap.put(parts[0], parts[1]);\n      }\n    }\n\n    if (!paramMap.containsKey(\"type\")) {\n      throw new IllegalArgumentException(\"Secret string must contain a valid type parameter\");\n    }\n\n    String rawType = paramMap.remove(\"type\");\n    if (rawType == null || rawType.isEmpty()) {\n      throw new IllegalArgumentException(\"Secret string must contain a valid type parameter\");\n    }\n\n    String secretType = rawType.toLowerCase();\n    SecretRegistrar.SecretFactory factory = SECRET_FACTORIES.get(secretType);\n    if (factory == null) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Invalid secret type %s, currently supported types: %s\", rawType, SUPPORTED_TYPES));\n    }\n\n    try {\n      return factory.createSecret(paramMap);\n    } catch (Exception e) {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/Secret.java#L199-L235","documentation":"parseSecretOption requires the option string to contain a 'type' parameter identifying which secret manager to use. If the parsed parameter map has no 'type' key, the option string is malformed and IllegalArgumentException is thrown.","triggerScenarios":"Calling Secret.parseSecretOption with a string lacking 'type:', e.g. \"version_name=my_secret/versions/latest\" or an empty/blank string that yields an empty parameter map.","commonSituations":"Typos in the option string (missing the type: prefix), copying only the version_name portion from documentation, or passing an empty string from an unset-but-not-null config value.","solutions":["Include the type parameter first in the option string, e.g. 'type:GcpSecret;version_name=my_secret/versions/latest'.","Check for typos such as 'Type:' or 'secret_type:' — the key must be exactly lowercase 'type'.","Validate the option string in your pipeline setup code before calling parseSecretOption."],"exampleFix":"// before\nSecret s = Secret.parseSecretOption(\"version_name:my_secret/versions/latest\");\n// after\nSecret s = Secret.parseSecretOption(\"type:GcpSecret;version_name:my_secret/versions/latest\");","handlingStrategy":"validation","validationCode":"boolean ok = secretOption != null && secretOption.matches(\".*(^|;)type:[^;]+.*\");\nif (!ok) { throw new IllegalArgumentException(\"secret option must start with 'type:<manager>;...\"); }","typeGuard":null,"tryCatchPattern":"try { Secret s = Secret.parseSecretOption(opt); } catch (IllegalArgumentException e) { LOG.error(\"malformed secret option: {}\", opt, e); throw e; }","preventionTips":["Always begin the option string with 'type:<SecretManager>'.","Keep an option-string constant/template in code instead of ad-hoc strings.","Lint config templates to ensure placeholders are substituted."],"tags":["java","beam","secrets","configuration","format"],"backgroundTag":"missing-required-config-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}