{"record":{"id":"2b026eb6fe636c9c","repo":"apache/beam","slug":"shardsnumber-must-be-greater-than-0","errorCode":null,"errorMessage":"shardsNumber must be greater than 0.","messagePattern":"shardsNumber must be greater than 0\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeWriteConfiguration.java","lineNumber":170,"sourceCode":"\n    String debugMode = getDebugMode();\n    if (debugMode != null) {\n      parseStreamingLogLevel(debugMode);\n    }\n\n    Integer flushRowLimit = getFlushRowLimit();\n    if (flushRowLimit != null && flushRowLimit <= 0) {\n      throw new IllegalArgumentException(\"flushRowLimit must be greater than 0.\");\n    }\n\n    Long flushTimeLimitMillis = getFlushTimeLimitMillis();\n    if (flushTimeLimitMillis != null && flushTimeLimitMillis <= 0) {\n      throw new IllegalArgumentException(\"flushTimeLimitMillis must be greater than 0.\");\n    }\n\n    Integer shardsNumber = getShardsNumber();\n    if (shardsNumber != null && shardsNumber <= 0) {\n      throw new IllegalArgumentException(\"shardsNumber must be greater than 0.\");\n    }\n  }\n\n  private static void requireNonEmpty(String value, String name) {\n    if (value == null || value.isEmpty()) {\n      throw new IllegalArgumentException(name + \" cannot be empty\");\n    }\n  }\n\n  @AutoValue.Builder\n  public abstract static class Builder {\n\n    public abstract Builder setServerName(String value);\n\n    public abstract Builder setUsername(@Nullable String value);\n\n    public abstract Builder setPassword(@Nullable String value);\n","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeWriteConfiguration.java#L152-L188","documentation":"validate() in SnowflakeWriteConfiguration rejects a shardsNumber that is set but not strictly positive. shardsNumber sets the number of parallel insert shards for streaming (SnowPipe) writes; zero or negative values cannot describe a shard count. The check fires only when the value is explicitly configured.","triggerScenarios":"Setting shardsNumber to 0 or a negative integer (e.g. .withShardsNumber(0)) on SnowflakeWriteConfiguration before pipeline validation.","commonSituations":"Shard count computed from a parallelism setting that defaults to 0, or a copied config where the field was left as 0 placeholder.","solutions":["Set shardsNumber to a positive integer (e.g. 2-8 depending on throughput) or leave it unset to use the default.","Fix the source of the computed value so unset parallelism yields null, not 0.","Only call withShardsNumber when the computed shard count is > 0."],"exampleFix":"// before\n.withShardsNumber(0)\n// after\n.withShardsNumber(4)","handlingStrategy":"validation","validationCode":"Integer shardsNumber = cfg.getShardsNumber();\nif (shardsNumber != null && shardsNumber <= 0) {\n  throw new IllegalArgumentException(\"shardsNumber must be > 0 or null\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"shardsNumber\")) { /* set a positive shard count, e.g. 4 */ }\n  throw e;\n}","preventionTips":["Compute shard counts with Math.max(1, computed) when derived from parallelism settings.","Omit the field entirely when the value is unknown instead of defaulting to 0.","Validate snowflake streaming config as part of CI for pipeline templates."],"tags":["java","configuration","snowflake","streaming"],"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-20T03:17:13.778Z"}