apache/beam · error · ValueError
input_type could only be 'bytes' or 'fileio'
Error message
input_type could only be 'bytes' or 'fileio'
What it means
apache_beam.io.gcp.healthcare.dicomio's client __init__ validates the input_type argument and raises ValueError if it is not exactly 'bytes' or 'fileio'. These are the only two input modes the DICOM API client supports for sourcing DICOM files, so any other value is rejected before an object is constructed.
Solutions
- Pass exactly input_type='bytes' when the source provides in-memory byte payloads.
- Pass exactly input_type='fileio' when the source provides Beam file objects / file paths to be read.
- Fix casing/typos: the comparison is case-sensitive lowercase.
Example fix
// before client = DicomClient(destination_dict, input_type='Bytes') // after client = DicomClient(destination_dict, input_type='bytes')
Defensive patterns
Strategy: validation
Validate before calling
if input_type not in ('bytes', 'fileio'):
raise ValueError(f"input_type must be 'bytes' or 'fileio', got {input_type!r}") Type guard
def valid_input_type(v):
return isinstance(v, str) and v in ('bytes', 'fileio') Try / catch
try:
client = DicomClient(destination_dict, input_type=input_type)
except ValueError as e:
if "input_type" in str(e):
log.error('Fix input_type in pipeline options; expected bytes|fileio')
raise Prevention
- Define an INPUT_TYPES = ('bytes', 'fileio') constant and validate config at pipeline setup
- Validate pipeline options once at job start, not inside transforms
- Watch casing: the check is case-sensitive lowercase
When it happens
Trigger: Calling dicomio client constructors (e.g. HttpDicomClient /DicomClient classes) with input_type set to anything other than the literal strings 'bytes' or 'fileio', including case variants like 'Bytes' or 'FILEIO'.
Common situations: Typos or wrong casing in pipeline configuration; passing a Python type object (bytes) or a placeholder value instead of the required string literals; reading the parameter name and passing a type instead of the enum-like string.
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
- Cannot skip negative number of header lines
- Must have in the dict.
- An unsupported sink was specified
- At least one of --render_port or --render_output must be…
- buffer_sec must be >= 0, got
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/75b97704b69dd877.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/io/gcp/healthcare/dicomio.py:458
* project_id: Id of the project in which DICOM store locates. (Required)
* region: Region where the DICOM store resides. (Required)
* dataset_id: Id of the dataset where DICOM store belongs to. (Required)
* dicom_store_id: Id of the dicom store. (Required)
input_type: # type: string, could only be 'bytes' or 'fileio'
buffer_size: # type: Int. Size of the request buffer.
max_workers: # type: Int. Maximum number of threads a worker can
create. If it is set to one, all the request will be processed
sequentially in a worker.
client: # type: object. If it is specified, all the Api calls will
made by this client instead of the default one (DicomApiHttpClient).
credential: # type: Google credential object, if it is specified, the
Http client will use it instead of the default one.
"""
self.destination_dict = destination_dict
# input_type pre-check
if input_type not in ['bytes', 'fileio']:
raise ValueError("input_type could only be 'bytes' or 'fileio'")
self.input_type = input_type
self.buffer_size = buffer_size
self.max_workers = max_workers
self.client = client
self.credential = credential
def expand(self, pcoll):
return pcoll | beam.ParDo(
_StoreInstance(
self.destination_dict,
self.input_type,
self.buffer_size,
self.max_workers,
self.client,
self.credential))
class _StoreInstance(beam.DoFn):View on GitHub (pinned to 12126d8942)