{"record":{"id":"b2ed5deb1c28a9d5","repo":"apache/beam","slug":"no-op-handler-should-not-be-closed-this-implies-this-io-is","errorCode":null,"errorMessage":"No Op handler should not be closed. This implies this IO is misconfigured.","messagePattern":"No Op handler should not be closed\\. This implies this IO is misconfigured\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/errorhandling/ErrorHandler.java","lineNumber":228,"sourceCode":"      super(sinkTransform, pipeline, BadRecord.getCoder(pipeline));\n    }\n  }\n\n  /**\n   * A default, placeholder error handler that exists to allow usage of .addErrorCollection()\n   * without effects. This enables more simple codepaths without checking for whether the user\n   * configured an error handler or not.\n   */\n  @Internal\n  class DefaultErrorHandler<ErrorT, OutputT extends POutput>\n      implements ErrorHandler<ErrorT, OutputT> {\n\n    @Override\n    public void addErrorCollection(PCollection<ErrorT> errorCollection) {}\n\n    @Override\n    public boolean isClosed() {\n      throw new IllegalArgumentException(\n          \"No Op handler should not be closed. This implies this IO is misconfigured.\");\n    }\n\n    @Override\n    public @Nullable OutputT getOutput() {\n      throw new IllegalArgumentException(\n          \"No Op handler has no output. This implies this IO is misconfigured.\");\n    }\n\n    @Override\n    public void close() {\n      throw new IllegalArgumentException(\n          \"No Op handler should not be closed. This implies this IO is misconfigured.\");\n    }\n  }\n}\n","sourceCodeStart":210,"sourceCodeEnd":245,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/errorhandling/ErrorHandler.java#L210-L245","documentation":"NoOpErrorHandler.isClosed always throws IllegalArgumentException because a No-Op handler represents a deliberately absent error handler. Querying its lifecycle state means an IO asked for error-handler metadata it should never need, indicating the IO was misconfigured to use the No-Op handler as a real one.","triggerScenarios":"An IO connector or framework code calls isClosed() on ErrorHandler.getNoOpHandler() — e.g. lifecycle checks in generic error-handler plumbing applied to a pipeline built without a real error handler.","commonSituations":"Passing the No-Op singleton where a DefaultErrorHandler is expected; generic code paths that poll isClosed() on any ErrorHandler implementation; refactor after removing a real handler but leaving polling logic.","solutions":["Use a real (Default)ErrorHandler if lifecycle queries are needed.","Change the IO configuration to supply a genuine error handler.","Remove/guard the isClosed() polling in generic code so it skips No-Op handlers."],"exampleFix":"// before\nif (errorHandler.isClosed()) { ... } // throws for NoOp\n// after\nif (!(errorHandler instanceof ErrorHandler.NoOpErrorHandler) && errorHandler.isClosed()) { ... }","handlingStrategy":"type-guard","validationCode":"if (errorHandler instanceof ErrorHandler.NoOpErrorHandler) { /* skip lifecycle checks */ }","typeGuard":"boolean isRealHandler(ErrorHandler<?> h) {\n  return !(h instanceof ErrorHandler.NoOpErrorHandler);\n}","tryCatchPattern":"try {\n  errorHandler.isClosed();\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"No-Op handler queried for lifecycle; IO misconfigured\", e);\n}","preventionTips":["Never pass ErrorHandler.getNoOpHandler() where lifecycle management is expected","Check the handler type before generic lifecycle plumbing runs","Configure a real handler for IOs that query handler state"],"tags":["java","apache-beam","error-handling","no-op-handler","misconfiguration"],"backgroundTag":"invalid-config-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}