{"record":{"id":"27a3bc1aa00d52c1","repo":"theonedev/onedev","slug":"the-request-should-have-either-pageid-or-resour","errorCode":null,"errorMessage":"The request should have either 'pageId' or 'resourceName' parameter!","messagePattern":"The request should have either 'pageId' or 'resourceName' parameter!","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java","lineNumber":122,"sourceCode":"\t *      the http request that was used to create the TomcatWebSocketProcessor\n\t * @param application\n\t *      the current Wicket Application\n\t */\n\tpublic AbstractWebSocketProcessor(final HttpServletRequest request, final WebApplication application)\n\t{\n\t\tfinal HttpSession httpSession = request.getSession(true);\n\t\tif (httpSession == null)\n\t\t{\n\t\t\tthrow new IllegalStateException(\"There is no HTTP Session bound. Without a session Wicket won't be \" +\n\t\t\t\t\t\"able to find the stored page to update its components\");\n\t\t}\n\t\tthis.sessionId = httpSession.getId();\n\n\t\tString pageId = request.getParameter(\"pageId\");\n\t\tresourceName = request.getParameter(\"resourceName\");\n\t\tif (Strings.isEmpty(pageId) && Strings.isEmpty(resourceName))\n\t\t{\n\t\t\tthrow new IllegalArgumentException(\"The request should have either 'pageId' or 'resourceName' parameter!\");\n\t\t}\n\t\tif (Strings.isEmpty(pageId) == false)\n\t\t{\n\t\t\tthis.pageId = Integer.parseInt(pageId, 10);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthis.pageId = NO_PAGE_ID;\n\t\t}\n\n\t\tString baseUrl = request.getParameter(WebRequest.PARAM_AJAX_BASE_URL);\n\t\tChecks.notNull(baseUrl, String.format(\"Request parameter '%s' is required!\", WebRequest.PARAM_AJAX_BASE_URL));\n\t\tthis.baseUrl = Url.parse(baseUrl);\n\n\t\tWicketFilter wicketFilter = application.getWicketFilter();\n\t\tthis.servletRequest = new ServletRequestCopy(request);\n\n\t\tthis.application = Args.notNull(application, \"application\");","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java#L104-L140","documentation":"Wicket's AbstractWebSocketProcessor requires every WebSocket upgrade request to identify its target: either a 'pageId' parameter (a page-scoped connection) or a 'resourceName' parameter (an application-scoped WebSocket resource). If both are empty the constructor throws IllegalArgumentException because there is no valid registry key to attach the connection to. This is a programming or configuration error in how the WebSocket endpoint URL was built.","triggerScenarios":"Constructing AbstractWebSocketProcessor (or a subclass) with an HttpServletRequest whose query string lacks both 'pageId' and 'resourceName'; hand-crafting a WebSocket connect URL without the parameters Wicket's WebSocketBehavior normally appends; a reverse proxy stripping query parameters.","commonSituations":"Manually writing JS like new WebSocket('ws://host/wicket/websocket') without the pageId/resourceName query params; proxy configs rewriting the URL; upgrading Wicket versions where the resource path changed so old hardcoded URLs miss parameters.","solutions":["Use Wicket's WebSocketRequestHandler/WebSocketBehavior-generated connection URL instead of hardcoding it, so pageId/resourceName are always appended","For an application-scoped connection, mount the WebSocket resource with a resourceName and include ?resourceName=<name> in the URL","For a page-scoped connection, render the URL via the page containing the WebSocketBehavior so ?pageId=<page id> is included","Log the incoming request URL to confirm no proxy/filter strips the query string"],"exampleFix":"// before\nnew WebSocket('ws://host/wicket/websocket');\n// after\n// let Wicket generate the URL from the behavior's callback script,\n// which appends e.g. ?pageId=1 (page-scoped) or ?resourceName=echo (app-scoped)","handlingStrategy":"validation","validationCode":"// before opening the WS connection\nconst params = new URLSearchParams(url);\nif (!params.has('pageId') && !params.has('resourceName')) {\n  throw new Error('WebSocket URL must include pageId or resourceName');\n}","typeGuard":null,"tryCatchPattern":"// server-side\ntry {\n    new MyWebSocketProcessor(request);\n} catch (IllegalArgumentException e) {\n    log.warn(\"WebSocket request missing pageId/resourceName: {}\", request.getRequestURL());\n    // reject the upgrade\n}","preventionTips":["Always obtain the WS URL from Wicket-generated callback script, never hardcode","For app-scoped sockets include ?resourceName= in the URL","Verify proxies don't strip query strings","Write an integration test that performs the WS handshake with the mounted resource"],"tags":["websocket","wicket","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}