{"record":{"id":"59b93db24145e410","repo":"apache/beam","slug":"attempt-to-case-match-on-unknown-s-subclass-s","errorCode":null,"errorMessage":"Attempt to case match on unknown %s subclass %s","messagePattern":"Attempt to case match on unknown (.+?) subclass (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnSignature.java","lineNumber":362,"sourceCode":"        return cases.dispatch((TimerFamilyParameter) this);\n      } else if (this instanceof TimerIdParameter) {\n        return cases.dispatch((TimerIdParameter) this);\n      } else if (this instanceof BundleFinalizerParameter) {\n        return cases.dispatch((BundleFinalizerParameter) this);\n      } else if (this instanceof CausedByDrainParameter) {\n        return cases.dispatch((CausedByDrainParameter) this);\n      } else if (this instanceof CurrentRecordIdParameter) {\n        return cases.dispatch((CurrentRecordIdParameter) this);\n      } else if (this instanceof CurrentRecordOffsetParameter) {\n        return cases.dispatch((CurrentRecordOffsetParameter) this);\n      } else if (this instanceof FireTimestampParameter) {\n        return cases.dispatch((FireTimestampParameter) this);\n      } else if (this instanceof ValueKindParameter) {\n        return cases.dispatch((ValueKindParameter) this);\n      } else if (this instanceof KeyParameter) {\n        return cases.dispatch((KeyParameter) this);\n      } else {\n        throw new IllegalStateException(\n            String.format(\n                \"Attempt to case match on unknown %s subclass %s\",\n                Parameter.class.getCanonicalName(), this.getClass().getCanonicalName()));\n      }\n    }\n\n    /** An interface for destructuring a {@link Parameter}. */\n    public interface Cases<ResultT> {\n      ResultT dispatch(StartBundleContextParameter p);\n\n      ResultT dispatch(FinishBundleContextParameter p);\n\n      ResultT dispatch(ProcessContextParameter p);\n\n      ResultT dispatch(ElementParameter p);\n\n      ResultT dispatch(SchemaElementParameter p);\n","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnSignature.java#L344-L380","documentation":"DoFnSignature.Parameter.match() is a closed visitor dispatch: it maps every known Parameter subclass (ElementParameter, TimerParameter, StateParameter, RestrictionTrackerParameter, etc.) to a case. If a Parameter instance is of a type the cases object does not know (or a new Parameter subtype was added without extending the cases), an IllegalStateException is thrown.","triggerScenarios":"Adding a new Parameter subclass to DoFnSignature without updating all match() call sites; constructing a custom Parameter subtype; an internal bug where a cases object implements only a subset of dispatch methods.","commonSituations":"Upgrading Apache Beam and vendoring a custom DoFnSignature visitor that now misses new parameter kinds; library development/patching of the reflection package.","solutions":["Extend the cases object to dispatch the unknown Parameter subclass (implement its dispatch method)","If you vendored/patched this code, re-sync with the upstream Beam version that introduced the new Parameter type","File a bug with the concrete subclass name in the message if it appears with an unmodified Beam version"],"exampleFix":"// before\n// cases implements dispatch(ElementParameter), dispatch(TimerParameter)... missing new kind\n// after\nclass MyCases implements Parameter.Cases<ReturnT> {\n  public ReturnT dispatch(NewParameter p) { return handleNew(p); }\n  ...\n}","handlingStrategy":"try-catch","validationCode":"if (param.getClass().getCanonicalName().startsWith(\"org.apache.beam.sdk.transforms.reflect.DoFnSignature$\")) {\n  // known Parameter subtype; ensure cases implements its dispatch\n}","typeGuard":"boolean isKnownParameter(DoFnSignature.Parameter p) {\n  return p instanceof DoFnSignature.ElementParameter\n      || p instanceof DoFnSignature.TimerParameter\n      || p instanceof DoFnSignature.StateParameter\n      || p instanceof DoFnSignature.KeyParameter;\n}","tryCatchPattern":"try {\n  return param.match(cases);\n} catch (IllegalStateException e) {\n  log.error(\"Unknown Parameter subclass: {}\", e.getMessage());\n  throw e;\n}","preventionTips":["When adding a Parameter subclass, update every Cases implementation","Parameter.Cases implementations should be exhaustive; prefer compiler-checked visitor interfaces","After Beam upgrades, re-check custom visitors against new signature types"],"tags":["java","apache-beam","visitor-pattern","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}