{"record":{"id":"accae2fe644c3ffa","repo":"cube-js/cube","slug":"ksql-api-error-for-body-ksql-any-e-resp","errorCode":null,"errorMessage":"ksql API error for '${body.ksql}': ${(<any>e).response?.data?.message || (<any>e).response?.statusCode || (<any>e).message || (<any>e).toString()}","messagePattern":"ksql API error for '(.+?)': (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-ksql-driver/src/KsqlDriver.ts","lineNumber":156,"sourceCode":"          mechanism: 'plain',\n          username: this.config.kafkaUser,\n          password: this.config.kafkaPassword || ''\n        } : undefined,\n      });\n    }\n  }\n\n  private async apiQuery(path: string, body: any): Promise<AxiosResponse> {\n    const url = `${this.config.url}${path}`;\n    try {\n      return await axios.post(url, body, {\n        auth: {\n          username: this.config.username,\n          password: this.config.password,\n        },\n      });\n    } catch (e) {\n      throw new Error(\n        `ksql API error for '${\n          body.ksql\n        }': ${\n          (<any>e).response?.data?.message ||\n          (<any>e).response?.statusCode ||\n          (<any>e).message ||\n          (<any>e).toString()\n        }`\n      );\n    }\n  }\n\n  protected prepareQueryWithParams(query: string, values?: unknown[]): string {\n    return formatAnsi(query, values || []);\n  }\n\n  public async query<R = unknown>(query: string, values?: unknown[], options: KsqlQueryOptions = {}): Promise<R> {\n    if (query.toLowerCase().startsWith('select')) {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-ksql-driver/src/KsqlDriver.ts#L138-L174","documentation":"apiQuery wraps any axios failure against the ksql REST endpoint (auth errors, wrong URL/port, ksqlDB server errors, network failures) into a single error that embeds the submitted KSQL statement and the best available server-provided detail (response.data.message, status code, or axios error). It marks the failure as a ksqlDB API problem for the given statement, not a Cube-side compilation issue.","triggerScenarios":"Thrown at packages/cubejs-ksql-driver/src/KsqlDriver.ts:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check e.response.data.message first for the ksqlDB server error text (syntax error, unknown stream/table, auth failure) and fix the ksql statement accordingly","Verify this.config.url, username and password are correct and the ksql server is reachable","If e.response.statusCode is present (e.g. 401/403), fix authentication; if the message is a connect error, fix the URL/network"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}