{"record":{"id":"8ef5591b86737c43","repo":"apache/beam","slug":"empty-argument-value-is-only-allowed-for-string-string-array","errorCode":null,"errorMessage":"Empty argument value is only allowed for String, String Array, Collections of Strings or any of these types in a parameterized ValueProvider, but received: %s","messagePattern":"Empty argument value is only allowed for String, String Array, Collections of Strings or any of these types in a parameterized ValueProvider, but received: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java","lineNumber":2053,"sourceCode":"    JavaType unwrappedType =\n        type.equals(ValueProvider.class) ? genericType.containedType(0) : genericType;\n\n    Class<?> containedType = unwrappedType.getRawClass();\n    if (unwrappedType.getRawClass().isArray()) {\n      containedType = unwrappedType.getRawClass().getComponentType();\n    } else if (Collection.class.isAssignableFrom(unwrappedType.getRawClass())) {\n      JavaType innerType = unwrappedType.containedType(0);\n      // Note that raw types are allowed, hence the null check.\n      containedType = innerType == null ? String.class : innerType.getRawClass();\n    }\n    if (!containedType.equals(String.class)) {\n      String msg =\n          String.format(\n              \"Empty argument value is only allowed for String, String Array, Collections of\"\n                  + \" Strings or any of these types in a parameterized ValueProvider, but\"\n                  + \" received: %s\",\n              genericTypeName);\n      throw new IllegalArgumentException(msg);\n    }\n  }\n\n  /** Hold all data which can change after a classloader change. */\n  static final class Cache {\n    private final Map<String, Class<? extends PipelineRunner<?>>> supportedPipelineRunners;\n\n    /** The set of options that have been registered and visible to the user. */\n    private final Set<Class<? extends PipelineOptions>> registeredOptions =\n        Sets.newConcurrentHashSet();\n\n    /** A cache storing a mapping from a given interface to its registration record. */\n    private final Map<Class<? extends PipelineOptions>, Registration<?>> interfaceCache =\n        Maps.newConcurrentMap();\n\n    /** A cache storing a mapping from a set of interfaces to its registration record. */\n    private final Map<Set<Class<? extends PipelineOptions>>, Registration<?>> combinedCache =\n        Maps.newConcurrentMap();","sourceCodeStart":2035,"sourceCodeEnd":2071,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java#L2035-L2071","documentation":"An empty string option value was given for a type that cannot accept emptiness. Beam only allows empty values for String, String arrays, Collections of Strings, or ValueProviders parameterized by these; anything else throws IllegalArgumentException naming the generic type.","triggerScenarios":"Passing --someIntOption= or an empty JSON value for an Integer/long/complex-typed property via fromArgs or the options JSON map.","commonSituations":"Unset environment variable interpolated into --flag=${ENV} producing an empty value; template variables left blank; scripts building arg lists with missing defaults.","solutions":["Provide a real value for the option or remove the flag entirely so defaults apply","Change the option type to String (or a String collection) if empty is a legitimate state","Check upstream env vars/variables feeding the argument list for empty expansions"],"exampleFix":"// before\n--numWorkers=${NUM_WORKERS}   // NUM_WORKERS empty\n// after\n--numWorkers=${NUM_WORKERS:-4}","handlingStrategy":"validation","validationCode":"String v = \"--numWorkers=\" + System.getenv().getOrDefault(\"NUM_WORKERS\", \"\").trim();\nif (v.endsWith(\"=\")) throw new IllegalArgumentException(\"empty value for int option\");","typeGuard":null,"tryCatchPattern":"try { factory.fromArgs(args).as(Opts.class); } catch (IllegalArgumentException e) { /* supply defaults for empty args */ }","preventionTips":["Use ${VAR:-default} expansions in shell scripts","Strip trailing empty flags from generated arg lists","Only type String options as String if emptiness is meaningful"],"tags":["java","apache-beam","cli","empty-value","pipeline-options"],"backgroundTag":"empty-required-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"}