{"record":{"id":"32921e1daf4a4dff","repo":"cube-js/cube","slug":"error-as-error-message-error","errorCode":null,"errorMessage":"(error as Error).message || error","messagePattern":"\\(error as Error\\)\\.message \\|\\| error","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"packages/cubejs-server-core/src/core/DevServer.ts","lineNumber":636,"sourceCode":"\n      /**\n       * Important note:\n       * JS code for pre-agg includes the content of the pre-aggregation object\n       * without name, which is passed as preAggregationName.\n       * While yaml code for pre-agg includes whole yaml object including name.\n       */\n      const schemaConverter = new CubeSchemaConverter(this.cubejsServer.repository, [\n        new CubePreAggregationConverter({\n          cubeName,\n          preAggregationName,\n          code\n        })\n      ]);\n\n      try {\n        await schemaConverter.generate(cubeName);\n      } catch (error) {\n        return res.status(400).json({ error: (error as Error).message || error });\n      }\n\n      const file = schemaConverter.getSourceFiles().find(\n        ({ cubeName: currentCubeName }) => currentCubeName === cubeName\n      );\n\n      if (!file) {\n        return res.status(400).json({ error: `The schema file for \"${cubeName}\" cube was not found or could not be updated. Only JS and non-templated YAML files are supported.` });\n      }\n\n      this.cubejsServer.repository.writeDataSchemaFile(file.fileName, file.source);\n      return res.json('ok');\n    }));\n  }\n\n  protected getIdentifier(apiSecret: string): string {\n    return crypto.createHash('md5')\n      .update(apiSecret)","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-server-core/src/core/DevServer.ts#L618-L654","documentation":"Not a thrown error: in DevServer's pre-aggregation code conversion endpoint, CubeSchemaConverter.generate() failures (schema parse/compile errors in the submitted pre-aggregation code) are caught and returned as HTTP 400 with the error message instead of crashing the dev server.","triggerScenarios":"Thrown at packages/cubejs-server-core/src/core/DevServer.ts:636 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Review the returned message — it describes the schema compilation problem in the converted pre-aggregation code.","Check that the pre-aggregation definition (measures, dimensions, timeDimension, granularity) references existing cube members.","Fix the pre-aggregation code in the data model and retry the conversion."],"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"}