{"record":{"id":"0259135c9dcebbdb","repo":"apache/beam","slug":"subspace-for-spec-type-not-found","errorCode":null,"errorMessage":"subspace for {spec_type} not found.","messagePattern":"subspace for (.+?) not found\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/anomaly/specifiable.py","lineNumber":89,"sourceCode":"  if hasattr(cls, \"mro\"):\n    # some classes do not have \"mro\", such as functions.\n    for c in cls.mro():\n      if c.__name__ in _ACCEPTED_SUBSPACES:\n        return c.__name__\n\n  return _FALLBACK_SUBSPACE\n\n\ndef _spec_type_to_subspace(spec_type: str) -> str:\n  \"\"\"\n  Look for the subspace for a spec type. This is usually called to retrieve\n  the subspace of a registered specifiable class.\n  \"\"\"\n  for subspace in _ACCEPTED_SUBSPACES:\n    if spec_type in _KNOWN_SPECIFIABLE[subspace]:\n      return subspace\n\n  raise ValueError(f\"subspace for {spec_type} not found.\")\n\n\n@dataclasses.dataclass(frozen=True)\nclass Spec():\n  \"\"\"\n  Dataclass for storing specifications of specifiable objects.\n  Objects can be initialized using the data in their corresponding spec.\n  \"\"\"\n  #: A string indicating the concrete `Specifiable` class\n  type: str\n  #: An optional dictionary of keyword arguments for the `__init__` method of\n  #: the class. If None, when we materialize this Spec, we only return the\n  #: class without instantiate any objects from it.\n  config: Optional[dict[str, Any]] = dataclasses.field(default_factory=dict)\n\n\ndef _specifiable_from_spec_helper(v, _run_init):\n  if isinstance(v, Spec):","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/anomaly/specifiable.py#L71-L107","documentation":"_spec_type_to_subspace maps a Spec type string to the subspace (e.g. detector, transformation, scalers) where its registered Specifiable class lives. If the type is not registered in any known subspace in _KNOWN_SPECIFIABLE, a ValueError naming the type is raised. from_spec calls this before looking up the concrete subclass.","triggerScenarios":"Calling Specifiable.from_spec with a Spec whose .type string is not registered, is misspelled, or refers to a class that was never registered via the @specifiable decorator; also triggered by test_default_inference_fn with unknown types.","commonSituations":"Typos in spec type strings ('zscore' vs 'ZScore'); custom detectors used in a spec without registering them; Beam version changes renaming built-in spec types; deserialized specs from older pipeline definitions.","solutions":["Check the exact registered type string via Specifiable classes / _KNOWN_SPECIFIABLE and fix the Spec.type spelling.","Decorate your custom class with @specifiable so it registers in a subspace.","Register the type before from_spec runs (imports must execute the registration code).","If migrating from an older Beam release, update spec type names to the current registry."],"exampleFix":"// before\nSpec(type=\"RobustZ\" , config=None)\n// after\nSpec(type=\"RobustZScore\", config=None)","handlingStrategy":"try-catch","validationCode":"from apache_beam.ml.anomaly import specifiable\nassert any(spec.type in known for known in specifiable._KNOWN_SPECIFIABLE.values()), f\"unregistered type: {spec.type}\"","typeGuard":"def is_registered_type(t): return any(t in known for known in _KNOWN_SPECIFIABLE.values())","tryCatchPattern":"try:\n    obj = Specifiable.from_spec(spec)\nexcept ValueError as e:\n    logger.error(\"bad spec type %r: %s\", spec.type, e)\n    raise","preventionTips":["Copy type strings from the registry instead of typing them by hand","Register custom classes with @specifiable and import the module","Pin Beam versions and re-validate persisted specs after upgrades"],"tags":["python","anomaly-detection","registry","spec"],"backgroundTag":"invalid-enum-value","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"}