{"record":{"id":"39013217594d75df","repo":"apache/beam","slug":"unrecognized-value-pattern","errorCode":null,"errorMessage":"Unrecognized value pattern.","messagePattern":"Unrecognized value pattern\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/resources.py","lineNumber":134,"sourceCode":"      raise ValueError(\"Input must be a string or integer.\")\n\n    value = value.strip().replace(\" \", \"\")\n    units = {\n        'PiB': 2**50,\n        'TiB': 2**40,\n        'GiB': 2**30,\n        'MiB': 2**20,\n        'KiB': 2**10,\n        'PB': 10**15,\n        'TB': 10**12,\n        'GB': 10**9,\n        'MB': 10**6,\n        'KB': 10**3,\n        'B': 1,\n    }\n    match = re.match(r'.*?(\\D+)$', value)\n    if not match:\n      raise ValueError(\"Unrecognized value pattern.\")\n\n    suffix = match.group(1)\n    if suffix not in units:\n      raise ValueError(\"Unrecognized unit.\")\n    multiplier = units[suffix]\n    value = value[:-len(suffix)]\n\n    return str(round(float(value) * multiplier)).encode('ascii')\n\n  @staticmethod\n  def _use_max(v1, v2):\n    return str(max(int(v1), int(v2))).encode('ascii')\n\n  @staticmethod\n  def _use_sum(v1, v2):\n    return str(int(v1) + int(v2)).encode('ascii')\n\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/resources.py#L116-L152","documentation":"_parse_storage_size_str parses a storage size string like '512MB' by regex-extracting a trailing non-digit suffix. If the value contains no trailing non-digit characters (i.e., it is purely numeric with no unit), the regex fails to match and this error is raised. The library requires every storage size to carry an explicit unit suffix.","triggerScenarios":"Calling parse_resource_hints with a storage hint value like '100' or '100 ' with no unit suffix; the regex r'.*?(\\D+)$' returns None and ValueError('Unrecognized value pattern.') is raised.","commonSituations":"Users specify resource hints in pipeline options or YAML templates and forget the unit (e.g. 'memory_mb=1024' instead of '1024MB'); values copied from configs where the unit lives in the key name rather than the value.","solutions":["Add a unit suffix to the value, e.g. '100' -> '100MB' or '1024KB'.","Check that the value does not have hidden whitespace or non-ASCII digits preventing the suffix regex from matching.","If the unit should be implied, pre-normalize the string before passing it as a hint."],"exampleFix":"// before\noptions.view_as(DebugOptions).add_resource_hint('memory_mb=1024')\n// after\noptions.view_as(DebugOptions).add_resource_hint('memory_mb=1024MB')  # unit suffix required","handlingStrategy":"validation","validationCode":"import re\nassert re.search(r'\\d+[KMGT]?B?$', value) and re.search(r'\\D', value), f\"storage value {value!r} needs a unit suffix (e.g. '512MB')\"","typeGuard":"def has_unit_suffix(value: str) -> bool:\n    return bool(re.search(r'\\D', value)) and isinstance(value, str)","tryCatchPattern":"try:\n    hints = parse_resource_hints(raw_hints)\nexcept ValueError as e:\n    if 'Unrecognized value pattern' in str(e):\n        log.error('Storage hint %r lacks a unit suffix (e.g. 512MB)', e); raise","preventionTips":["Always include a unit suffix (B/KB/MB/GB/TB) in storage hint values.","Validate all resource hint values at config load time.","Keep units out of keys and into values consistently."],"tags":["python","apache-beam","resource-hints","value-format"],"backgroundTag":"invalid-argument-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"}