apache/beam · error · java.lang.IllegalArgumentException

Invalid boolean value

Error message

Invalid boolean value '%s'.

What it means

When converting a Snowflake STRING cell to a Beam BOOLEAN field, toBeamValue only accepts "true" or "false" (case-insensitive). Any other string — including "1"/"0", "yes"/"no", "t"/"f", or whitespace-padded values — throws an IllegalArgumentException with the offending value.

Solutions

  1. Fix the source data to emit exactly "true"/"false" (e.g. CAST(col AS VARCHAR) or IFF(col, 'true','false') in the query).
  2. Pre-normalize values in the pipeline before toRow (trim, map 1/0 to true/false).
  3. Change the Beam field type to STRING and convert manually with your own tolerant parser.

Example fix

// before
String value = "1"; // read from Snowflake export
// after
String value = "1".equals(raw) ? "true" : ("0".equals(raw) ? "false" : raw.trim());
Defensive patterns

Strategy: validation

Validate before calling

if (value == null || !("true".equalsIgnoreCase(value.trim()) || "false".equalsIgnoreCase(value.trim()))) {
  throw new IllegalArgumentException("not a boolean: " + value);
}

Try / catch

try { Row r = SnowflakeSchemaTransformUtils.toRow(parts, schema); }
catch (IllegalArgumentException e) { normalizeOrDeadLetter(parts, e); }

Prevention

When it happens

Trigger: A Snowflake BOOLEAN column exported as "1"/"0" or "TRUE "/"FALSE" with whitespace, or a VARCHAR column holding yes/no strings, read into a Beam FieldType.BOOLEAN via toRow.

Common situations: Snowflake-to-CSV exports rendering booleans as 1/0; untrimmed values from fixed-width exports; user-authored VARCHAR columns with human-readable truthiness strings.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/92aaaa6018361543. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeSchemaTransformUtils.java:244

        case FLOAT:
          return Float.valueOf(value);

        case DOUBLE:
          return Double.valueOf(value);

        case STRING:
          return value;

        case BOOLEAN:
          if ("true".equalsIgnoreCase(value)) {
            return true;
          }

          if ("false".equalsIgnoreCase(value)) {
            return false;
          }

          throw new IllegalArgumentException(String.format("Invalid boolean value '%s'.", value));

        case BYTES:
          return decodeHex(value);

        case DATETIME:
          return Instant.parse(value);

        case DECIMAL:
        case ARRAY:
        case ITERABLE:
        case MAP:
        case ROW:
        case LOGICAL_TYPE:
        default:
          throw unsupportedFieldType(field, null);
      }
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException(

View on GitHub (pinned to 12126d8942)