{"record":{"id":"3a59467d1bd16c24","repo":"apache/beam","slug":"unsupported-type-s-monitoring-info-proto-type","errorCode":null,"errorMessage":"'Unsupported type %s' % monitoring_info_proto.type","messagePattern":"'Unsupported type (.+?)' % monitoring_info_proto\\.type","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/metrics/monitoring_infos.py","lineNumber":138,"sourceCode":"SPANNER_PROJECT_ID = (\n    common_urns.monitoring_info_labels.SPANNER_PROJECT_ID.label_props.name)\nSPANNER_DATABASE_ID = (\n    common_urns.monitoring_info_labels.SPANNER_DATABASE_ID.label_props.name)\nSPANNER_TABLE_ID = (\n    common_urns.monitoring_info_labels.SPANNER_TABLE_ID.label_props.name)\nSPANNER_QUERY_NAME = (\n    common_urns.monitoring_info_labels.SPANNER_QUERY_NAME.label_props.name)\nBIGTABLE_PROJECT_ID_LABEL = (\n    common_urns.monitoring_info_labels.BIGTABLE_PROJECT_ID.label_props.name)\nINSTANCE_ID_LABEL = (\n    common_urns.monitoring_info_labels.INSTANCE_ID.label_props.name)\nTABLE_ID_LABEL = common_urns.monitoring_info_labels.TABLE_ID.label_props.name\n\n\ndef extract_counter_value(monitoring_info_proto):\n  \"\"\"Returns the counter value of the monitoring info.\"\"\"\n  if not is_counter(monitoring_info_proto):\n    raise ValueError('Unsupported type %s' % monitoring_info_proto.type)\n\n  # Only SUM_INT64_TYPE is currently supported.\n  return coders.VarIntCoder().decode(monitoring_info_proto.payload)\n\n\ndef extract_gauge_value(monitoring_info_proto):\n  \"\"\"Returns a tuple containing (timestamp, value)\"\"\"\n  if not is_gauge(monitoring_info_proto):\n    raise ValueError('Unsupported type %s' % monitoring_info_proto.type)\n\n  # Only LATEST_INT64_TYPE is currently supported.\n  return _decode_gauge(coders.VarIntCoder(), monitoring_info_proto.payload)\n\n\ndef extract_distribution(monitoring_info_proto):\n  \"\"\"Returns a tuple of (count, sum, min, max).\n\n  Args:","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/metrics/monitoring_infos.py#L120-L156","documentation":"extract_counter_value raises ValueError when the MonitoringInfo proto's type is not recognized as a counter (is_counter returns False). Only SUM_INT64_TYPE counters are supported for extraction, so any other type URL reaching this function is rejected. Callers normally route via extract_metric_result_map_value, which dispatches by type.","triggerScenarios":"Calling extract_counter_value on a MonitoringInfo whose type is a gauge, distribution, string-set, histogram, or bounded-trie type (or an unknown URN/type string).","commonSituations":"Runner-returned metrics with newer or runner-specific types not known to the client SDK version; manually routing monitoring infos to the wrong extractor after inspecting URNs by hand; SDK/runner version skew where the runner emits types this Beam version cannot decode.","solutions":["Use extract_metric_result_map_value instead of calling extract_counter_value directly so the correct extractor is chosen by type.","Filter monitoring infos with is_counter() before calling extract_counter_value.","Upgrade apache-beam to a version that recognizes the metric type being emitted by the runner."],"exampleFix":"// before\nvalue = extract_counter_value(mi)  # mi may be a gauge\n// after\nif is_counter(mi):\n    value = extract_counter_value(mi)\nelse:\n    value = extract_metric_result_map_value(mi)","handlingStrategy":"type-guard","validationCode":"from apache_beam.metrics.monitoring_infos import is_counter, extract_counter_value\nif is_counter(mi):\n    value = extract_counter_value(mi)","typeGuard":"def is_safe_counter(mi):\n    return is_counter(mi)","tryCatchPattern":"try:\n    value = extract_counter_value(mi)\nexcept ValueError as e:\n    logger.warning('skipping non-counter monitoring info: %s', e)\n    value = None","preventionTips":["Prefer extract_metric_result_map_value for metric result extraction.","Always check is_counter/is_gauge/is_distribution before targeted extractors.","Keep apache-beam client version aligned with the runner's emitted types."],"tags":["python","apache-beam","metrics","monitoring-info","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}