{"record":{"id":"b75ab52fad7d9737","repo":"apache/beam","slug":"unknown-spec-type-spec-type-in-spec","errorCode":null,"errorMessage":"Unknown spec type '{spec.type}' in {spec}","messagePattern":"Unknown spec type '(.+?)' in (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/anomaly/specifiable.py","lineNumber":175,"sourceCode":"                spec: Spec,\n                _run_init: bool = True) -> Union[Self, type[Self]]:\n    \"\"\"Generate a `Specifiable` subclass object based on a spec.\n\n    Args:\n      spec: the specification of a `Specifiable` subclass object\n      _run_init: whether to call `__init__` or not for the initial instantiation\n\n    Returns:\n      Self: the `Specifiable` subclass object\n    \"\"\"\n    if spec.type is None:\n      raise ValueError(f\"Spec type not found in {spec}\")\n\n    subspace = _spec_type_to_subspace(spec.type)\n    subclass: type[Self] = _KNOWN_SPECIFIABLE[subspace].get(spec.type, None)\n\n    if subclass is None:\n      raise ValueError(f\"Unknown spec type '{spec.type}' in {spec}\")\n\n    if spec.config is None:\n      # when functions or classes are used as arguments, we won't try to\n      # create an instance.\n      return subclass\n\n    kwargs = {\n        k: _specifiable_from_spec_helper(v, _run_init)\n        for k, v in spec.config.items()\n    }\n\n    if _run_init:\n      kwargs[\"_run_init\"] = True\n    return subclass(**kwargs)\n\n  def to_spec(self) -> Spec:\n    \"\"\"Generate a spec from a `Specifiable` subclass object.\n","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/anomaly/specifiable.py#L157-L193","documentation":"In Specifiable.from_spec, after the Spec has a type and the type's subspace is found, the concrete subclass is looked up in _KNOWN_SPECIFIABLE[subspace]. If the type is in a subspace key space but not actually registered there (or lookup misses), a ValueError 'Unknown spec type ...' is raised. It indicates the type string is not a registered Specifiable class.","triggerScenarios":"Passing a Spec whose .type string is not present in the registry for its subspace - misspelled built-in names, unregistered custom classes, or types from a different Beam version.","commonSituations":"Typos like 'z_score' vs 'ZScore'; custom detectors not decorated with @specifiable; pipeline specs serialized under an older Beam release whose registry differed; stale pickled Spec objects after upgrade.","solutions":["Correct Spec.type to the exact registered class name string.","Register the custom class with the @specifiable decorator before from_spec is called.","Confirm the module containing the class is imported so registration executes.","Regenerate/re-serialize old pipeline specs against the current Beam version's registry."],"exampleFix":"// before\n@dataclass\nclass MyDetector: ...  # never registered\nSpec(type=\"MyDetector\")\n// after\n@specifiable(\"MyDetector\", Subspace.DETECTOR)\nclass MyDetector(BaseDetector): ...\nSpec(type=\"MyDetector\")","handlingStrategy":"try-catch","validationCode":"known = set().union(*_KNOWN_SPECIFIABLE.values())\nif spec.type not in known:\n    raise ValueError(f\"unknown spec type: {spec.type!r}; known: {sorted(known)}\")","typeGuard":"def is_registered_spec(spec): return spec.type in set().union(*_KNOWN_SPECIFIABLE.values())","tryCatchPattern":"try:\n    obj = Specifiable.from_spec(spec)\nexcept ValueError as e:\n    logger.error(\"unknown spec type in %s: %s\", spec, e)\n    raise","preventionTips":["Use the exact registered class-name string in Spec.type","Decorate custom classes with @specifiable and ensure the module is imported","Re-serialize old pipeline specs after Beam 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"}