{"record":{"id":"4cd97dea8d7298c0","repo":"apache/beam","slug":"error-parsing-windowing-config-string-at-identify-object","errorCode":null,"errorMessage":"Error parsing windowing config string at {identify_object(spec)}: {e}","messagePattern":"Error parsing windowing config string at (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_transform.py","lineNumber":1118,"sourceCode":"def preprocess_windowing(spec):\n  if spec['type'] == 'WindowInto':\n    # This is the transform where it is actually applied.\n    if 'windowing' in spec:\n      spec['config'] = spec.get('config', {})\n      spec['config']['windowing'] = spec.pop('windowing')\n\n    if spec.get('config', {}).get('windowing'):\n      windowing_config = spec['config']['windowing']\n      if isinstance(windowing_config, str):\n        try:\n          # PyYAML can load a JSON string - one-line and multi-line.\n          # Without this code, multi-line is not supported.\n          parsed_config = yaml.safe_load(windowing_config)\n          if not isinstance(parsed_config, dict):\n            raise TypeError('Windowing config string must be a YAML/JSON map.')\n          spec['config']['windowing'] = parsed_config\n        except Exception as e:\n          raise ValueError(\n              f'Error parsing windowing config string at \\\n                {identify_object(spec)}: {e}') from e\n    return spec\n  elif 'windowing' not in spec:\n    # Nothing to do.\n    return spec\n\n  if spec['type'] == 'composite':\n    # Apply the windowing to any reads, creates, etc. in this transform\n    # TODO(robertwb): Better handle the case where a read is followed by a\n    # setting of the timestamps. We should be careful of sliding windows\n    # in particular.\n    spec = push_windowing_to_roots(spec)\n\n  windowing = spec.pop('windowing')\n  if not is_empty(spec['input']):\n    # Apply the windowing to all inputs by wrapping it in a transform that\n    # first applies windowing and then applies the original transform.","sourceCodeStart":1100,"sourceCodeEnd":1136,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_transform.py#L1100-L1136","documentation":"When config.windowing is supplied as a string, preprocess_windowing parses it with yaml.safe_load; any failure — invalid YAML syntax or the parsed value not being a dict — is wrapped in this ValueError with the transform's identity and the underlying exception message. It exists to give context about which transform's windowing config is broken.","triggerScenarios":"preprocess_windowing on a spec whose windowing string is malformed YAML (e.g. 'type: fixed size:' unterminated) or parses to a non-dict (which first raises TypeError('Windowing config string must be a YAML/JSON map.') and is caught here and re-raised).","commonSituations":"Multi-line JSON strings with indentation errors; forgetting to quote a string containing YAML-special characters; typos in JSON like single quotes around keys in a JSON-style string.","solutions":["Fix the YAML/JSON syntax indicated by the wrapped exception e in the message.","Prefer expressing windowing as a native mapping in the spec to avoid string parsing entirely.","Validate the string with yaml.safe_load locally to see the exact parse error."],"exampleFix":"# before\nconfig:\n  windowing: \"{type: fixed, size: }\"\n# after\nconfig:\n  windowing:\n    type: fixed\n    size: 10s","handlingStrategy":"try-catch","validationCode":"import yaml\nw = spec.get('config', {}).get('windowing')\nif isinstance(w, str):\n    try:\n        yaml.safe_load(w)\n    except yaml.YAMLError as err:\n        print(f'invalid windowing YAML: {err}')","typeGuard":null,"tryCatchPattern":"try:\n    spec = preprocess_windowing(spec)\nexcept ValueError as e:\n    if 'Error parsing windowing config string' in str(e):\n        # e's cause shows the exact YAML/typing failure; fix and retry or surface\n        print(e)\n        raise","preventionTips":["Validate the windowing string with yaml.safe_load before submitting the pipeline","Use block-style mappings instead of inline strings for multi-line configs","Quote strings containing YAML special characters"],"tags":["python","apache-beam","yaml","windowing","parse-error"],"backgroundTag":"yaml-parse-error","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"}