{"record":{"id":"c807d3e1f41017e1","repo":"zaproxy/zaproxy","slug":"illegal-parameter-c807d3","errorCode":"ILLEGAL_PARAMETER","errorMessage":"ILLEGAL_PARAMETER: e.getMessage()","messagePattern":"ILLEGAL_PARAMETER: e\\.getMessage\\(\\)","errorType":"error_code","errorClass":"ApiException","httpStatus":400,"severity":"error","filePath":"zap/src/main/java/org/zaproxy/zap/extension/proxies/ProxiesAPI.java","lineNumber":111,"sourceCode":"        }\n    }\n\n    @Override\n    public ApiResponse handleApiAction(String name, JSONObject params) throws ApiException {\n        if (ACTION_ADD_PROXY.equals(name)) {\n            try {\n                extension.addProxy(\n                        new ProxiesParamProxy(\n                                params.getString(PARAM_ADDRESS),\n                                params.getInt(PARAM_PORT),\n                                true,\n                                false,\n                                this.getParam(params, PARAM_REM_UNSUPPORTED_ENC, false),\n                                this.getParam(params, PARAM_DECODE_ZIP, false),\n                                this.getParam(params, PARAM_BEHIND_NAT, false)));\n                return ApiResponseElement.OK;\n            } catch (Exception e) {\n                throw new ApiException(ApiException.Type.ILLEGAL_PARAMETER, e.getMessage());\n            }\n        } else if (ACTION_REMOVE_PROXY.equals(name)) {\n            try {\n                extension.removeProxy(params.getString(PARAM_ADDRESS), params.getInt(PARAM_PORT));\n                return ApiResponseElement.OK;\n            } catch (Exception e) {\n                throw new ApiException(ApiException.Type.ILLEGAL_PARAMETER, e.getMessage());\n            }\n        } else {\n            throw new ApiException(ApiException.Type.BAD_VIEW, name);\n        }\n    }\n}\n","sourceCodeStart":93,"sourceCodeEnd":125,"githubUrl":"https://github.com/zaproxy/zaproxy/blob/9d1970a436b1b189bfb588fc88864c80d9baf6a5/zap/src/main/java/org/zaproxy/zap/extension/proxies/ProxiesAPI.java#L93-L125","documentation":"ProxiesAPI.handleApiAction wraps any exception from extension.addProxy into ApiException(ILLEGAL_PARAMETER) carrying the underlying message. So 'proxy already exists' or 'cannot listen on' failures during the addProxy API action surface as ILLEGAL_PARAMETER.","triggerScenarios":"Calling proxies/action/addProxy/ where the address:port duplicates an existing proxy or cannot be bound (port occupied, invalid local address, privileged port), or with malformed 'port' that fails integer parsing.","commonSituations":"Automation re-adding an existing listener; port conflicts with other services; wrong type for port param (e.g. '8080x'); binding to a hostname that doesn't resolve to a local interface.","solutions":["Read e.getMessage() in the error detail to see whether it's 'Proxy already exists' or 'Cannot listen on' and act accordingly.","Check existing proxies via /JSON/proxies/view/additionalProxies/ before adding.","Ensure 'port' is sent as a valid integer and the address is a local interface.","Pick a free port and deduplicate add calls in setup scripts."],"exampleFix":"// before\ncurl \"http://zap:8080/JSON/proxies/action/addProxy/?port=8080\" // missing address -> ILLEGAL_PARAMETER\n// after\ncurl \"http://zap:8080/JSON/proxies/action/addProxy/?address=127.0.0.1&port=8091\"","handlingStrategy":"try-catch","validationCode":"boolean duplicate = getAdditionalProxy(address, port) != null;\nboolean bindable = canListenOn(address, port);\nif (duplicate || !bindable || !port.matches(\"\\\\d+\")) {\n    // fix inputs before calling /JSON/proxies/action/addProxy/\n}\n","typeGuard":null,"tryCatchPattern":"try {\n    api.call(\"/JSON/proxies/action/addProxy/?address=..&port=..\");\n} catch (ApiException e) {\n    if (e.getType() == ApiException.Type.ILLEGAL_PARAMETER) {\n        String detail = e.getMessage(); // 'Proxy already exists' vs 'Cannot listen on'\n    }\n}","preventionTips":["Parse e.getMessage() to distinguish duplicate vs unbindable causes.","Check additionalProxies and port availability before adding.","Always send address and integer port.","Make add calls idempotent."],"tags":["zap","api","proxy","illegal-parameter"],"backgroundTag":"invalid-api-parameter","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"}