{"record":{"id":"13d51cea887a3e40","repo":"cube-js/cube","slug":"unsupported-method-message-method","errorCode":null,"errorMessage":"Unsupported method: ${message.method}","messagePattern":"Unsupported method: (.+?)","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"warning","filePath":"packages/cubejs-api-gateway/src/ws/subscription-server.ts","lineNumber":158,"sourceCode":"      authContext = await this.subscriptionStore.getAuthContext(connectionId);\n      if (!authContext) {\n        await this.sendMessage(\n          connectionId,\n          {\n            messageId: message.messageId,\n            message: { error: 'Not authorized' },\n            status: 403\n          }\n        );\n        return;\n      }\n\n      if (!message.method) {\n        throw new UserError('Method is required');\n      }\n\n      if (!methodParams.hasOwnProperty(message.method)) {\n        throw new UserError(`Unsupported method: ${message.method}`);\n      }\n\n      const subscriptionId = message.messageId;\n      const baseRequestId = message.requestId || `${connectionId}-${subscriptionId}`;\n      const requestId = `${baseRequestId}-span-${uuidv4()}`;\n\n      context = await this.apiGateway.contextByReq(\n        // TODO: We need to standardize type for WS request type\n        message as any,\n        authContext.securityContext,\n        requestId\n      );\n\n      this.apiGateway.log({\n        type: 'Incoming network usage',\n        service: 'api-ws',\n        bytes,\n      }, context);","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-api-gateway/src/ws/subscription-server.ts#L140-L176","documentation":"After checking that a `method` field is present, handleMessage verifies it against the allow-list in `methodParams` via hasOwnProperty. Any method name not registered on this subscription server is rejected with UserError('Unsupported method: <name>'). This guards against calling non-existent or forbidden WS methods.","triggerScenarios":"Client sends a WS message whose `method` value is not one of the registered keys (e.g. `sql`, `subscribe` on a server where it is not configured), such as `{ method: 'fetch' }`.","commonSituations":"Typos in method names ('Load' vs 'load'), clients copied from older Cube examples using renamed methods, or expecting SQL-over-WS methods that are not exposed by the gateway configuration.","solutions":["Use a supported method name: check methodParams in subscription-server.ts for the allowed keys (load, subscribe, etc.)","Fix casing — method names are matched exactly (case-sensitive hasOwnProperty)","If the method should exist, ensure the API gateway registers the corresponding handler"],"exampleFix":"// before\nsocket.send(JSON.stringify({ messageId: '1', method: 'Load', params }))\n// after\nsocket.send(JSON.stringify({ messageId: '1', method: 'load', params }))","handlingStrategy":"validation","validationCode":"const SUPPORTED_METHODS = ['load', 'subscribe', 'unsubscribe', 'meta'] // check subscription-server methodParams\nfunction sendWsMessage(socket, msg) {\n  if (!SUPPORTED_METHODS.includes(msg.method)) throw new TypeError(`Unsupported method: ${msg.method}`)\n  socket.send(JSON.stringify(msg))\n}","typeGuard":"function isSupportedMethod(m: unknown): m is { method: 'load' | 'subscribe' | 'unsubscribe' } {\n  return !!m && typeof m === 'object' && ['load','subscribe','unsubscribe'].includes((m as any).method)\n}","tryCatchPattern":"socket.on('message', raw => {\n  const msg = JSON.parse(raw)\n  if (msg.error && /Unsupported method/.test(msg.error)) {\n    console.error(`Cube WS: method '${msg.method}' not allowed — check methodParams`)\n    return\n  }\n})","preventionTips":["Use the official Cube WS client which only emits registered methods","Method names are case-sensitive — keep a shared constant for them","Consult subscription-server.ts methodParams for the authoritative list before adding new calls"],"tags":["websocket","validation","api-misuse"],"backgroundTag":"unsupported-api-method","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}