{"record":{"id":"ea0341a9e0e1df39","repo":"zaproxy/zaproxy","slug":"the-interface-error-message-provider-must-not-be-s","errorCode":null,"errorMessage":"The interface error message provider must not be set if using an interface provider.","messagePattern":"The interface error message provider must not be set if using an interface provider\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"zap/src/main/java/org/zaproxy/zap/extension/script/ScriptsCache.java","lineNumber":390,"sourceCode":"            /**\n             * Builds the configuration from the specified data.\n             *\n             * @return the build configuration.\n             * @throws IllegalStateException if the script type or the target interface is not set.\n             *     Or, the interface error message provider is set at the same time as the interface\n             *     provider. The error message provider is not used when using an interface\n             *     provider.\n             */\n            public final Configuration<T> build() {\n                if (scriptType == null || scriptType.isEmpty()) {\n                    throw new IllegalStateException(\"The script type must be set.\");\n                }\n                if (targetInterface == null) {\n                    throw new IllegalStateException(\"The target interface must be set.\");\n                }\n\n                if (interfaceProvider != null && interfaceErrorMessageProvider != null) {\n                    throw new IllegalStateException(\n                            \"The interface error message provider must not be set if using an interface provider.\");\n                }\n\n                return new Configuration<>(\n                        scriptType,\n                        targetInterface,\n                        interfaceProvider,\n                        interfaceErrorMessageProvider);\n            }\n        }\n    }\n\n    /**\n     * An action applied on a script, through the interface.\n     *\n     * @param <T> the type of the interface.\n     */\n    public interface ScriptAction<T> {","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/zaproxy/zaproxy/blob/9d1970a436b1b189bfb588fc88864c80d9baf6a5/zap/src/main/java/org/zaproxy/zap/extension/script/ScriptsCache.java#L372-L408","documentation":"A ScriptsCache Configuration may provide either an interfaceProvider (which supplies the script instance directly) or an interfaceErrorMessageProvider (for default providers) — but build() throws IllegalStateException if both are set, because the error message provider is meaningless when an interface provider is used.","triggerScenarios":"Calling both .setInterfaceProvider(...) and .setInterfaceErrorMessageProvider(...) on the same Configuration builder before .build().","commonSituations":"Add-on code copied from two different examples that each set one of the options; incremental refactoring that added an interface provider but left the old error-message provider in place.","solutions":["Remove the setInterfaceErrorMessageProvider call when using an interfaceProvider","Keep interfaceErrorMessageProvider only for configurations using the default script-loading path","Split into two separate Configurations if both behaviors are needed"],"exampleFix":"// before\nConfiguration<MyApi> cfg = new Configuration<MyApi>()\n    .setScriptType(\"my-type\")\n    .setTargetInterface(MyApi.class)\n    .setInterfaceProvider(s -> myImpl)\n    .setInterfaceErrorMessageProvider(s -> \"err\")\n    .build();\n// after\nConfiguration<MyApi> cfg = new Configuration<MyApi>()\n    .setScriptType(\"my-type\")\n    .setTargetInterface(MyApi.class)\n    .setInterfaceProvider(s -> myImpl)\n    .build();","handlingStrategy":"validation","validationCode":"if (interfaceProvider != null && interfaceErrorMessageProvider != null) throw new IllegalStateException(\"choose one provider style\");","typeGuard":null,"tryCatchPattern":"try { cfg = builder.build(); } catch (IllegalStateException e) { log.error(\"Conflicting providers: {}\", e.getMessage()); }","preventionTips":["Pick one provider style per Configuration","Comment builder code to note which provider pattern is in use","Remove legacy interfaceErrorMessageProvider calls when migrating to interfaceProvider"],"tags":["java","illegal-state","builder-validation","mutually-exclusive","zaproxy"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"9d1970a436b1b189bfb588fc88864c80d9baf6a5","analyzedAt":"2026-09-05T19:26:59.356Z","contentChangedAt":"2026-09-05T19:26:59.356Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}