{"record":{"id":"efd822d6dd0e2ccd","repo":"cube-js/cube","slug":"data-model-on-branch-has-compilation-error-s","errorCode":null,"errorMessage":"data model on {branch} has {} compilation error(s)","messagePattern":"data model on (.+?) has (.+?) compilation error\\(s\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cube-cli/src/commands/validate.rs","lineNumber":132,"sourceCode":"        for error in &errors {\n            eprintln!(\"  {}\", format_error(error));\n        }\n    }\n\n    if !valid {\n        // Non-zero exit is the point of the command in CI, so it holds in\n        // --json mode too, where the report above was printed as JSON.\n        //\n        // With nothing to list there is no stderr header above it: the header\n        // exists to introduce a list, and repeating the verdict on two lines\n        // says less than the one line that also says what to look at.\n        if errors.is_empty() {\n            bail!(\n                \"data model on {branch} could not be validated \\\n                 (the API reported a failure without any compilation errors)\"\n            );\n        }\n        bail!(\n            \"data model on {branch} has {} compilation error(s)\",\n            errors.len()\n        );\n    }\n\n    Ok(())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use serde_json::json;\n\n    #[test]\n    fn an_error_is_prefixed_with_the_file_only_when_the_compiler_named_one() {\n        assert_eq!(\n            format_error(&json!({\"fileName\": \"model/cubes/orders.yml\", \"message\": \"no sql\"})),\n            \"model/cubes/orders.yml: no sql\"","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube-cli/src/commands/validate.rs#L114-L150","documentation":"`cube validate` compares the branch's data model against the API's compiler and, when compilation errors are returned, bails with this message summarizing the error count. The detailed errors are printed just above (as a list, or JSON with --json); the bail message is the final verdict.","triggerScenarios":"Running `cube validate --branch <branch>` where the API's compiler returns one or more compilation errors for the branch's data model (schema YAML/JS syntax errors, invalid cubes, bad joins).","commonSituations":"A recent commit introduced a broken data model file; merged PRs with conflicting schema changes; invalid environment variable references in the model.","solutions":["Read the compilation errors printed above the message and fix the listed data model files","Re-run `cube validate` until it passes before deploying","Validate locally with the Cube dev server to catch errors before pushing"],"exampleFix":"// before (broken model)\ncube: my_cube\n  sql: SELECT FROM\n// after\ncube: my_cube\n  sql: SELECT * FROM public.events","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  run(`cube validate --branch ${branch}`);\n} catch (e) {\n  if (String(e).includes(\"compilation error(s)\")) {\n    console.error(\"Fix data model errors printed above before deploying\");\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Run `cube validate` in CI on every data model change","Validate locally with the Cube dev server before pushing","Keep schema files linted and reviewed before merging"],"tags":["cli","validate","data-model","compilation"],"backgroundTag":"schema-compilation-failed","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}