cubejs/cube:v0.35.11 results in Model files not found errors
Describe the bug When we use any version of cubejs/cube past v0.35.10, our cube deployment results in the following errors:
"error": "Error: Model files not found. Please make sure the "model" directory exists and contains model files.", "stack": "Error: Model files not found. Please make sure the "model" directory exists and contains model files.\n at FileRepository.getFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:31:13)\n at FileRepository.dataSchemaFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:46:19)\n at DataSchemaCompiler.doCompile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:81:19)\n at CompilerApi.getCompilers (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:67:26)\n at CompilerApi.metaConfig (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:221:23)\n at ApiGateway.load (/cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:1597:30)\n at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:257:7"
We are deploying cube to aks following a similar chart structure as what is documented here: https://github.com/cube-js/cube/tree/master/examples/kubernetes/cluster
To Reproduce Steps to reproduce the behavior:
- Use cubejs/cube:v0.35.11 or greater
- Have cube image deployed with cube.js file in root
- Port forward cube-api service: kubectl port-forward -n cube svc/cube-api 4000
- Make a test api call to http://localhost:4000/cubejs-api/v1/load with a valid query parameter included
- See the error in api output and cube-api pod logs
Expected behavior Expect the api results to come back with valid data from our ConfigMap that was specified in the query parameter of the call.
Screenshots
If applicable, add screenshots to help explain your problem.
Version: v0.35.11 through latest does not work
Example cube.js file in root
module.exports = {
checkAuth: ({ securityContext }, token) => {
if (token !== null) {
return;
}
throw new Error(`Access denied - securityContext: ${securityContext} - token: ${token}`);
},
orchestratorOptions: {
continueWaitTimeout: 15
}
};
@alyssakelley schema path should be updated to be model indeed.
The solution is updating cube.js in the root of the image to be something similar to:
const path = require("path");
const fs = require("fs");
module.exports = {
checkAuth: ({ securityContext }, token) => {
if (token !== null) {
return;
}
throw new Error(`Access denied - securityContext: ${securityContext} - token: ${token}`);
},
orchestratorOptions: {
continueWaitTimeout: 15
},
repositoryFactory: () => ({
dataSchemaFiles: async () => {
const files = await fs.promises.readdir(
path.join(process.cwd(), "model")
);
return await Promise.all(
files
.filter((file) => file.endsWith(".js") || file.endsWith(".yaml"))
.map(async (file) => ({
fileName: file,
content: await fs.promises.readFile(
path.join(process.cwd(), "model", file),
"utf-8"
),
}))
);
},
})
};
and then making sure the volume mount is updated in the cube-api deployment
The problem still remains, providing a workaround is appreciated but is not a solution. I believe this ticket should be re-opened.
It happens to me as well when upgreading cube from 34 to 35 (latest one). All my existing queries failed with:
"error": "Error: Model files not found. Please make sure the \"model\" directory exists and contains model files.",
"stack": "Error: Model files not found. Please make sure the \"model\" directory exists and contains model files.\n at FileRepository.getFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:31:13)\n at FileRepository.dataSchemaFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:46:19)\n at CompilerApi.getCompilers (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:55:21)\n at CompilerApi.metaConfig (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:231:23)\n at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:273:28",
"requestId": "cc639dca-c76e-4135-8ce4-c9d522fde3ff-span-1"
Hi @paveltiunov , do we have any guideline doc on upgrading cube from 34 to 35, as we encounter this issue
"error": "Error: Model files not found. Please make sure the \"model\" directory exists and contains model files.",
"stack": "Error: Model files not found. Please make sure the \"model\" directory exists and contains model files.\n at FileRepository.getFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:31:13)\n at FileRepository.dataSchemaFiles (/cube/node_modules/@cubejs-backend/shared/src/FileRepository.ts:46:19)\n at CompilerApi.getCompilers (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:55:21)\n at CompilerApi.metaConfig (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:231:23)\n at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:273:28",
"requestId": "cc639dca-c76e-4135-8ce4-c9d522fde3ff-span-1"
when we did the upgrade, this is one of the breaking change mentioned here, however, it has no guideline on how to resolve these breaking changes. Any helpful doc or hints would be much appreciated.
I resolved by explicitly adding the path in the config (following the doc here):
module.exports = {
schemaPath: 'my-data-model'
};