apache/beam · error · RuntimeError

Write disposition has to be one of the following…

Error message

Write disposition has to be one of the following values:APPEND, EMPTY, TRUNCATE. Got: {}

What it means

In Beam's Snowflake connector, WriteDisposition.VerifyParam checks that the write-disposition string is one of the class constants APPEND, EMPTY, or TRUNCATE. It raises RuntimeError when a truthy value matches no defined attribute, preventing invalid Snowflake table write modes.

Solutions

  1. Use WriteDisposition.APPEND, WriteDisposition.EMPTY, or WriteDisposition.TRUNCATE constants
  2. Fix casing — the string must exactly match the uppercase constant name
  3. Replace unsupported synonyms like OVERWRITE with TRUNCATE
  4. Pass None/empty to leave the disposition unset (verification is skipped when falsy)

Example fix

// before
snowflake.WriteToSnowflake(write_disposition='overwrite')
// after
from apache_beam.io.snowflake import WriteDisposition
snowflake.WriteToSnowflake(write_disposition=WriteDisposition.TRUNCATE)
Defensive patterns

Strategy: validation

Validate before calling

from apache_beam.io.snowflake import WriteDisposition
assert write_disposition in (None, '', WriteDisposition.APPEND, WriteDisposition.EMPTY, WriteDisposition.TRUNCATE)

Type guard

def is_valid_write_disposition(v):
    return not v or v in ('APPEND', 'EMPTY', 'TRUNCATE')

Try / catch

try:
    transform = snowflake.WriteToSnowflake(write_disposition=wd)
except RuntimeError as e:
    logger.error('Invalid write disposition: %s', e)

Prevention

When it happens

Trigger: Passing a write_disposition like 'append' (wrong case), 'OVERWRITE' (not supported), or any misspelled string to a Snowflake write transform.

Common situations: Translating SQL-style or other-connector dispositions (e.g. 'OVERWRITE' instead of 'TRUNCATE'), or lowercase config values from environment/YAML files.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/io/snowflake.py:479


class WriteDisposition:
  """
  Enum class for possible values of write dispositions:
  APPEND: Default behaviour. Written data is added to the existing rows
  in the table,
  EMPTY: The target table must be empty;  otherwise, the write operation fails,
  TRUNCATE: The write operation deletes all rows from the target table
  before writing to it.
  """
  APPEND = 'APPEND'
  EMPTY = 'EMPTY'
  TRUNCATE = 'TRUNCATE'

  @staticmethod
  def VerifyParam(field):
    if field and not hasattr(WriteDisposition, field):
      raise RuntimeError(
          'Write disposition has to be one of the following values:'
          'APPEND, EMPTY, TRUNCATE. Got: {}'.format(field))


def verify_credentials(
    username, password, private_key_path, raw_private_key, o_auth_token):
  if not (o_auth_token or (username and password) or
          (username and (private_key_path or raw_private_key))):
    raise RuntimeError('Snowflake credentials are not set correctly.')

View on GitHub (pinned to 12126d8942)