{"record":{"id":"75b97704b69dd877","repo":"apache/beam","slug":"input-type-could-only-be-bytes-or-fileio","errorCode":null,"errorMessage":"input_type could only be 'bytes' or 'fileio'","messagePattern":"input_type could only be 'bytes' or 'fileio'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/healthcare/dicomio.py","lineNumber":458,"sourceCode":"      * project_id: Id of the project in which DICOM store locates. (Required)\n      * region: Region where the DICOM store resides. (Required)\n      * dataset_id: Id of the dataset where DICOM store belongs to. (Required)\n      * dicom_store_id: Id of the dicom store. (Required)\n\n      input_type: # type: string, could only be 'bytes' or 'fileio'\n      buffer_size: # type: Int. Size of the request buffer.\n      max_workers: # type: Int. Maximum number of threads a worker can\n      create. If it is set to one, all the request will be processed\n      sequentially in a worker.\n      client: # type: object. If it is specified, all the Api calls will\n      made by this client instead of the default one (DicomApiHttpClient).\n      credential: # type: Google credential object, if it is specified, the\n      Http client will use it instead of the default one.\n    \"\"\"\n    self.destination_dict = destination_dict\n    # input_type pre-check\n    if input_type not in ['bytes', 'fileio']:\n      raise ValueError(\"input_type could only be 'bytes' or 'fileio'\")\n    self.input_type = input_type\n    self.buffer_size = buffer_size\n    self.max_workers = max_workers\n    self.client = client\n    self.credential = credential\n\n  def expand(self, pcoll):\n    return pcoll | beam.ParDo(\n        _StoreInstance(\n            self.destination_dict,\n            self.input_type,\n            self.buffer_size,\n            self.max_workers,\n            self.client,\n            self.credential))\n\n\nclass _StoreInstance(beam.DoFn):","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/healthcare/dicomio.py#L440-L476","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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."],"exampleFix":"// before\nclient = DicomClient(destination_dict, input_type='Bytes')\n// after\nclient = DicomClient(destination_dict, input_type='bytes')","handlingStrategy":"validation","validationCode":"if input_type not in ('bytes', 'fileio'):\n    raise ValueError(f\"input_type must be 'bytes' or 'fileio', got {input_type!r}\")","typeGuard":"def valid_input_type(v):\n    return isinstance(v, str) and v in ('bytes', 'fileio')","tryCatchPattern":"try:\n    client = DicomClient(destination_dict, input_type=input_type)\nexcept ValueError as e:\n    if \"input_type\" in str(e):\n        log.error('Fix input_type in pipeline options; expected bytes|fileio')\n    raise","preventionTips":["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"],"tags":["validation","constructor-argument","dicom","python","apache-beam"],"backgroundTag":"invalid-enum-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"}