{"record":{"id":"8a9a5996033a9767","repo":"apache/beam","slug":"not-supported","errorCode":null,"errorMessage":"Not supported.","messagePattern":"Not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/translate/collector/SingleValueCollector.java","lineNumber":65,"sourceCode":"\n  public SingleValueCollector(AccumulatorProvider accumulators, @Nullable String operatorName) {\n    this.accumulators = accumulators;\n    this.operatorName = operatorName;\n  }\n\n  public T get() {\n    return elem;\n  }\n\n  @Override\n  public void collect(T elem) {\n    this.elem = elem;\n  }\n\n  @Override\n  public Context asContext() {\n    // this is not needed, the underlying functor does not have access to this\n    throw new UnsupportedOperationException(\"Not supported.\");\n  }\n\n  @Override\n  public Counter getCounter(String name) {\n    return accumulators.getCounter(requireNonNull(operatorName, UNSUPPORTED), name);\n  }\n\n  @Override\n  public Histogram getHistogram(String name) {\n    return accumulators.getHistogram(requireNonNull(operatorName, UNSUPPORTED), name);\n  }\n\n  @Override\n  public Timer getTimer(String name) {\n    return accumulators.getTimer(name);\n  }\n}\n","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/translate/collector/SingleValueCollector.java#L47-L83","documentation":"SingleValueCollector.asContext always throws UnsupportedOperationException; the collector wraps a single element directly and intentionally has no Context view, because the underlying functor never needs one.","triggerScenarios":"Calling collector.asContext() on a SingleValueCollector, e.g. generic code that treats every collector uniformly and requests a context for accumulator/timer operations.","commonSituations":"Framework-style user code iterating collectors of different kinds; someone attempting to use context-based (windowed/element-context) APIs in a single-value collection.","solutions":["Do not call asContext() on single-value collectors; use the collector's direct methods (getCounter, getHistogram, collect)","Branch on collector type before calling asContext()","Restructure code so context-based access happens only in element collectors"],"exampleFix":"// before\nContext ctx = collector.asContext();\n// after\nif (collector instanceof ElementCollector) { Context ctx = ((ElementCollector) collector).asContext(); }","handlingStrategy":"type-guard","validationCode":"if (collector instanceof SingleValueCollector) { /* don't call asContext() */ }","typeGuard":"Optional<Context> tryAsContext(Collector<?> c) { return (c instanceof SingleValueCollector) ? Optional.empty() : Optional.of(((ElementCollector<?>) c).asContext()); }","tryCatchPattern":"try { ctx = collector.asContext(); } catch (UnsupportedOperationException e) { /* use direct collector methods instead */ }","preventionTips":["Only request Context from element collectors","Branch on collector type in generic utility code","Prefer collector.getCounter/getHistogram over context access"],"tags":["unsupported-operation","collector","context","beam"],"backgroundTag":"operation-not-supported","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"}