{"record":{"id":"074b6d8c2cc66b92","repo":"apache/beam","slug":"path-must-not-be-empty","errorCode":null,"errorMessage":"Path must not be empty.","messagePattern":"Path must not be empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/internal/code_object_pickler.py","lineNumber":436,"sourceCode":"            return obj_\n  raise AttributeError(f'Could not find code object with path: {path}')\n\n\ndef get_code_from_identifier(code_object_identifier: str):\n  \"\"\"Returns the code object corresponding to the code object identifier.\n\n  Args:\n    code_object_identifier: A string representing the code object identifier.\n\n  Returns:\n    The code object.\n\n  Raises:\n    ValueError: If the path is empty or invalid.\n    AttributeError: If the attribute is not found.\n  \"\"\"\n  if not code_object_identifier:\n    raise ValueError('Path must not be empty.')\n  parts = code_object_identifier.split('.')\n  if parts[0] not in sys.modules:\n    raise AttributeError(f'Module {parts[0]} not found in sys.modules')\n  obj = sys.modules[parts[0]]\n  for part in parts[1:]:\n    if name_result := _SINGLE_NAME_PATTERN.fullmatch(part):\n      obj = _get_code_object_from_single_name_pattern(\n          obj, name_result, code_object_identifier)\n    elif lambda_with_args_result := _LAMBDA_WITH_ARGS_PATTERN.fullmatch(part):\n      obj = _get_code_object_from_lambda_with_args_pattern(\n          obj, lambda_with_args_result, code_object_identifier)\n    elif lambda_with_hash_result := _LAMBDA_WITH_HASH_PATTERN.fullmatch(part):\n      obj = _get_code_object_from_lambda_with_hash_pattern(\n          obj, lambda_with_hash_result, code_object_identifier)\n    elif default_result := _DEFAULT_PATTERN.fullmatch(part):\n      index = int(default_result.group(2))\n      if index >= len(obj.__defaults__):\n        raise ValueError(","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/internal/code_object_pickler.py#L418-L454","documentation":"get_code_from_identifier validates that the identifier string is non-empty before splitting on dots. An empty (or falsy) identifier is rejected with ValueError 'Path must not be empty.' This guards upstream callers (_make_function_from_identifier) from passing uninitialized path data.","triggerScenarios":"Calling get_code_from_identifier('') directly, or _make_function_from_identifier receiving an empty/None code-object identifier, typically from an empty attribute name extracted during pickling or a corrupted/blank serialized reference.","commonSituations":"A pickled payload missing the identifier field; code that builds the path via string concatenation ending up empty; reading function names from metadata that failed to populate.","solutions":["Check the identifier is non-empty before calling; fix the code that produced the empty string.","Guard with `if identifier:` and skip/fail fast with context about where it came from.","Inspect the pickling source that generated the reference to see why the name was blank."],"exampleFix":"// before\nfn = _make_function_from_identifier(identifier)  # identifier == ''\n// after\nif not identifier:\n    raise ValueError(f'Cannot unpickle function: empty identifier from {ctx}')\nfn = _make_function_from_identifier(identifier)","handlingStrategy":"validation","validationCode":"def ensure_nonempty(path):\n    if not path:\n        raise ValueError('code object identifier is empty; upstream pickling produced no name')\n    return path","typeGuard":"def is_valid_identifier(path) -> bool:\n    return isinstance(path, str) and bool(path.strip())","tryCatchPattern":"try:\n    fn = _make_function_from_identifier(ident)\nexcept ValueError as e:\n    raise RuntimeError(f'Blank function identifier from serialized reference: {e}') from e","preventionTips":["Validate serialized payloads contain the identifier field before unpickling.","Never build paths via unchecked string concatenation.","Log provenance of identifiers to debug blank-name sources."],"tags":["python","apache-beam","pickling","empty-input"],"backgroundTag":"empty-required-field","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"}