cube-js/cube · error · UserError
Python Parsing Error: ${this.errors.map(({ msg, column, line
Error message
Python Parsing Error:
${this.errors.map(({ msg, column, line }) => `${line}:${column} ${msg}`).join('\n')} What it means
Aggregated parse-error report thrown by PythonParser.throwErrorsIfAny(). The ANTLR lexer/parser listeners collect every syntax error (message, line, column) instead of failing fast; after parsing, parsePythonAndTranspileToJs calls throwErrorsIfAny() which raises a UserError listing all errors as 'line:column msg' lines. It means the Python in the data model file is not syntactically valid.
Source
Thrown at packages/cubejs-schema-compiler/src/parser/PythonParser.ts:270
}
}));
}
public stripQuotes(text: string): string {
if (text[0] === '"' && text[text.length - 1] === '"' || text[0] === '\'' && text[text.length - 1] === '\'') {
return text.slice(1, text.length - 1);
} else {
return text;
}
}
public canParse() {
return !this.errors.length;
}
public throwErrorsIfAny() {
if (this.errors.length) {
throw new UserError(
`Python Parsing Error:\n${this.errors.map(({ msg, column, line }) => `${line}:${column} ${msg}`).join('\n')}`
);
}
}
}
View on GitHub (pinned to 7d981676b3)
Solutions
- Read the line:column entries in the message and fix each reported syntax error in the Python data model file
- Validate the file with a real Python interpreter (python -m py_compile cubes.py) before restarting Cube
- Normalize indentation to consistent 4 spaces and check for missing colons/parentheses
- If the syntax is valid Python 3 but still rejected, check whether the embedded ANTLR grammar supports that version's features
Example fix
// before (cubes.py)
def cube_fn(x)
return x
// after
def cube_fn(x):
return x Defensive patterns
Strategy: validation
Validate before calling
const { execSync } = require('child_process');
try {
execSync('python3 -m py_compile cubes.py', { stdio: 'pipe' });
} catch (e) {
throw new Error('cubes.py has syntax errors; fix before starting Cube');
} Try / catch
try {
compiler.compile();
} catch (e) {
if (e instanceof UserError && e.message.startsWith('Python Parsing Error:')) {
console.error(e.message); // shows line:column for each error
process.exitCode = 1;
} else { throw e; }
} Prevention
- Run python3 -m py_compile on every model file in CI before Cube starts
- Use a Python-aware editor/linter (flake8, ruff) on data-model files
- Normalize indentation (4 spaces, no tabs) and check colons/brackets
- Parse errors list all issues at once — fix them top to bottom
When it happens
Trigger: Any call path that parses Python data-model files (parsePythonAndTranspileToJs -> throwErrorsIfAny) where the ANTLR Python3 lexer/parser recorded at least one syntaxError — e.g. bad indentation, missing colon, unbalanced quotes/parens in cubes.py.
Common situations: Syntax slips while editing Python schemas: wrong indentation (tabs vs spaces), missing ':' after def/if, stray characters, truncated files from failed saves, or Python-version-specific syntax the grammar doesn't accept.
Related errors
- SQL Parsing Error: ${this.errors.map(({ msg, column, line })
- Unsupported Python multiple children node: ${node.constructo
- Empty Python atom_expr node: ${node.constructor.name}: ${nod
- Unsupported Python Trailer children node: ${node.constructor
- Unsupported Python vfpdef children node: ${node.constructor.
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/b62790cc3d192e2b.
Report an issue: GitHub.