{"record":{"id":"1869e2c5fc884013","repo":"apache/beam","slug":"invalid-tag-r","errorCode":null,"errorMessage":"Invalid tag %r","messagePattern":"Invalid tag %r","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/sideinputs.py","lineNumber":74,"sourceCode":"\n  if isinstance(target_window_fn, window.Sessions):\n    raise RuntimeError(\"Sessions is not allowed in side inputs\")\n\n  def map_via_end(source_window: window.BoundedWindow) -> window.BoundedWindow:\n    return list(\n        target_window_fn.assign(\n            window.WindowFn.AssignContext(\n                source_window.max_timestamp(), window=source_window)))[-1]\n\n  return map_via_end\n\n\ndef get_sideinput_index(tag: str) -> int:\n  match = re.match(SIDE_INPUT_REGEX, tag, re.DOTALL)\n  if match:\n    return int(match.group(1))\n  else:\n    raise RuntimeError(\"Invalid tag %r\" % tag)\n\n\nclass SideInputMap(object):\n  \"\"\"Represents a mapping of windows to side input values.\"\"\"\n  def __init__(self, view_class: 'pvalue.AsSideInput', view_options, iterable):\n    self._window_mapping_fn = view_options.get(\n        'window_mapping_fn', _global_window_mapping_fn)\n    self._view_class = view_class\n    self._view_options = view_options\n    self._iterable = iterable\n    self._cache: dict[window.BoundedWindow, Any] = {}\n\n  def __getitem__(self, window: window.BoundedWindow) -> Any:\n    if window not in self._cache:\n      target_window = self._window_mapping_fn(window)\n      self._cache[window] = self._view_class._from_runtime_iterable(\n          _FilteringIterable(self._iterable, target_window), self._view_options)\n    return self._cache[window]","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/sideinputs.py#L56-L92","documentation":"Side input tags follow SIDE_INPUT_REGEX (typically 'ref_PCollection_side_N'). get_sideinput_index extracts the integer index N; a tag that does not match means the runner_api side-input reference is malformed. It indicates corrupted or hand-constructed pipeline proto data.","triggerScenarios":"from_runner_api/deserialize receives a side-input tag string that fails SIDE_INPUT_REGEX (e.g. missing '_side_' portion, arbitrary key from user code); called during pipeline construction from from_runner_api_parameter.","commonSituations":"Hand-editing or transforming a serialized pipeline JSON/proto; passing runner-internal tag keys where an index-bearing tag is expected; runner/portable layers producing nonstandard tags after version mismatch.","solutions":["Inspect the pipeline proto/JSON and correct the side input tag to the expected 'ref_PCollection_side_<N>' form.","Regenerate the pipeline instead of manually editing serialized pipeline artifacts.","Check Beam SDK/runner version consistency if the malformed tag comes from a portable pipeline crossing SDK/container versions."],"exampleFix":"// before\ntag = 'ref_PCollection_3'  # not a side-input tag\nidx = get_sideinput_index(tag)\n// after\ntag = 'ref_PCollection_side_3'\nidx = get_sideinput_index(tag)","handlingStrategy":"type-guard","validationCode":"import re\nSIDE_INPUT_REGEX = re.compile(r'ref_PCollection_side_(\\d+)', re.DOTALL)\nassert SIDE_INPUT_REGEX.match(tag), f\"tag {tag!r} is not a side-input reference\"","typeGuard":"def is_side_input_tag(tag: str) -> bool:\n    import re\n    return isinstance(tag, str) and re.match(r'ref_PCollection_side_\\d+$', tag, re.DOTALL) is not None","tryCatchPattern":"try:\n    idx = get_sideinput_index(tag)\nexcept RuntimeError as e:\n    log.error('Malformed side-input tag %r; regenerate the pipeline proto', tag)\n    raise","preventionTips":["Never hand-edit serialized pipeline protos/JSON.","Keep SDK and runner container versions in sync in portable pipelines.","Validate pipeline artifacts after custom proto transformations."],"tags":["python","apache-beam","side-inputs","runner-api"],"backgroundTag":"invalid-identifier-format","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"}