apache/beam · error · ValueError
subspace for not found.
Error message
subspace for {spec_type} not found. What it means
_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.
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.
Example fix
// before Spec(type="RobustZ" , config=None) // after Spec(type="RobustZScore", config=None)
Defensive patterns
Strategy: try-catch
Validate before calling
from apache_beam.ml.anomaly import specifiable
assert any(spec.type in known for known in specifiable._KNOWN_SPECIFIABLE.values()), f"unregistered type: {spec.type}" Type guard
def is_registered_type(t): return any(t in known for known in _KNOWN_SPECIFIABLE.values())
Try / catch
try:
obj = Specifiable.from_spec(spec)
except ValueError as e:
logger.error("bad spec type %r: %s", spec.type, e)
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- Unknown spec type ' ' in
- 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/0259135c9dcebbdb.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/anomaly/specifiable.py:89
if hasattr(cls, "mro"):
# some classes do not have "mro", such as functions.
for c in cls.mro():
if c.__name__ in _ACCEPTED_SUBSPACES:
return c.__name__
return _FALLBACK_SUBSPACE
def _spec_type_to_subspace(spec_type: str) -> str:
"""
Look for the subspace for a spec type. This is usually called to retrieve
the subspace of a registered specifiable class.
"""
for subspace in _ACCEPTED_SUBSPACES:
if spec_type in _KNOWN_SPECIFIABLE[subspace]:
return subspace
raise ValueError(f"subspace for {spec_type} not found.")
@dataclasses.dataclass(frozen=True)
class Spec():
"""
Dataclass for storing specifications of specifiable objects.
Objects can be initialized using the data in their corresponding spec.
"""
#: A string indicating the concrete `Specifiable` class
type: str
#: An optional dictionary of keyword arguments for the `__init__` method of
#: the class. If None, when we materialize this Spec, we only return the
#: class without instantiate any objects from it.
config: Optional[dict[str, Any]] = dataclasses.field(default_factory=dict)
def _specifiable_from_spec_helper(v, _run_init):
if isinstance(v, Spec):View on GitHub (pinned to 12126d8942)