apache/beam · error · ValueError
Unknown spec type ' ' in
Error message
Unknown spec type '{spec.type}' in {spec} What it means
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.
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.
Example fix
// before
@dataclass
class MyDetector: ... # never registered
Spec(type="MyDetector")
// after
@specifiable("MyDetector", Subspace.DETECTOR)
class MyDetector(BaseDetector): ...
Spec(type="MyDetector") Defensive patterns
Strategy: try-catch
Validate before calling
known = set().union(*_KNOWN_SPECIFIABLE.values())
if spec.type not in known:
raise ValueError(f"unknown spec type: {spec.type!r}; known: {sorted(known)}") Type guard
def is_registered_spec(spec): return spec.type in set().union(*_KNOWN_SPECIFIABLE.values())
Try / catch
try:
obj = Specifiable.from_spec(spec)
except ValueError as e:
logger.error("unknown spec type in %s: %s", spec, e)
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- subspace for not found.
- Spec type not found in
- Coder registry has no fallback coder. This can happen if…
- "IQR.learn_one expected univariate input, but got
- "IQR.score_one expected univariate input, but got
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/b75ab52fad7d9737.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/anomaly/specifiable.py:175
spec: Spec,
_run_init: bool = True) -> Union[Self, type[Self]]:
"""Generate a `Specifiable` subclass object based on a spec.
Args:
spec: the specification of a `Specifiable` subclass object
_run_init: whether to call `__init__` or not for the initial instantiation
Returns:
Self: the `Specifiable` subclass object
"""
if spec.type is None:
raise ValueError(f"Spec type not found in {spec}")
subspace = _spec_type_to_subspace(spec.type)
subclass: type[Self] = _KNOWN_SPECIFIABLE[subspace].get(spec.type, None)
if subclass is None:
raise ValueError(f"Unknown spec type '{spec.type}' in {spec}")
if spec.config is None:
# when functions or classes are used as arguments, we won't try to
# create an instance.
return subclass
kwargs = {
k: _specifiable_from_spec_helper(v, _run_init)
for k, v in spec.config.items()
}
if _run_init:
kwargs["_run_init"] = True
return subclass(**kwargs)
def to_spec(self) -> Spec:
"""Generate a spec from a `Specifiable` subclass object.
View on GitHub (pinned to 12126d8942)