{"record":{"id":"85cb7536ba318f9f","repo":"apache/beam","slug":"failed-to-parse-secret-option","errorCode":null,"errorMessage":"Failed to parse secret option","messagePattern":"Failed to parse secret option","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/Secret.java","lineNumber":242,"sourceCode":"\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) {\n      if (e instanceof IllegalArgumentException) {\n        throw (IllegalArgumentException) e;\n      }\n      if (e instanceof NullPointerException) {\n        throw (NullPointerException) e;\n      }\n      throw new RuntimeException(\"Failed to parse secret option\", e);\n    }\n  }\n\n  /**\n   * Return a Secret instance based on secret_manager provider and secret specification JSON string.\n   *\n   * @param spec Secret string (raw secret or JSON specification string).\n   * @param secretManager Secret manager string (e.g. 'GoogleCloudSecretManager').\n   * @return An instance of Secret.\n   */\n  public static Secret fromJson(@Nullable String spec, @Nullable String secretManager) {\n    String smManager = secretManager != null ? secretManager.trim() : null;\n    if (smManager != null && smManager.isEmpty()) {\n      smManager = null;\n    }\n\n    Map<String, String> specMap = null;\n    if (spec != null && !spec.isEmpty()) {","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/Secret.java#L224-L260","documentation":"Wraps any non-IllegalArgumentException/NullPointerException failure raised while creating the Secret from the parsed parameters into a RuntimeException with message 'Failed to parse secret option'. It preserves the original cause, e.g. a factory throwing a checked/runtime error while resolving or validating secret parameters.","triggerScenarios":"Calling parseSecretOption with a syntactically valid option whose type-specific factory (e.g. GcpSecret.createSecret) throws an unexpected exception while processing the remaining parameters.","commonSituations":"Malformed parameter values for a valid type (e.g. bad project/version formats), a factory bug, or unexpected runtime failures inside the secret manager implementation.","solutions":["Inspect the cause chain (getCause()) to find the real failure raised by the secret factory.","Verify every parameter in the option string is expected by the chosen secret type (extra/misspelled params can break factories).","Catch RuntimeException around parseSecretOption at pipeline startup and fail with a clear configuration error message."],"exampleFix":"// before\nSecret s = Secret.parseSecretOption(opt); // opaque RuntimeException\n// after\ntry {\n  Secret s = Secret.parseSecretOption(opt);\n} catch (RuntimeException e) {\n  LOG.error(\"Bad secret option {}: {}\", opt, e.getCause(), e);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Secret s = Secret.parseSecretOption(opt); } catch (RuntimeException e) { Throwable cause = e.getCause(); LOG.error(\"secret option '{}' failed: {}\", opt, cause, e); throw new ConfigurationException(\"bad secret option\", e); }","preventionTips":["Match parameters to what the chosen secret type's factory expects.","Read the cause chain — the real error is wrapped.","Test secret option parsing at pipeline startup with real config values."],"tags":["java","beam","secrets","configuration","wrapped-exception"],"backgroundTag":"invalid-config-value","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"}