{"record":{"id":"b62790cc3d192e2b","repo":"cube-js/cube","slug":"python-parsing-error-this-errors-map-msg-co","errorCode":null,"errorMessage":"Python Parsing Error:\n${this.errors.map(({ msg, column, line }) => `${line}:${column} ${msg}`).join('\\n')}","messagePattern":"Python Parsing Error:\n(.+?)\\) => `(.+?):(.+?) (.+?)`\\)\\.join\\('\\\\n'\\)\\}","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/parser/PythonParser.ts","lineNumber":270,"sourceCode":"      }\n    }));\n  }\n\n  public stripQuotes(text: string): string {\n    if (text[0] === '\"' && text[text.length - 1] === '\"' || text[0] === '\\'' && text[text.length - 1] === '\\'') {\n      return text.slice(1, text.length - 1);\n    } else {\n      return text;\n    }\n  }\n\n  public canParse() {\n    return !this.errors.length;\n  }\n\n  public throwErrorsIfAny() {\n    if (this.errors.length) {\n      throw new UserError(\n        `Python Parsing Error:\\n${this.errors.map(({ msg, column, line }) => `${line}:${column} ${msg}`).join('\\n')}`\n      );\n    }\n  }\n}\n","sourceCodeStart":252,"sourceCodeEnd":276,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/parser/PythonParser.ts#L252-L276","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (cubes.py)\ndef cube_fn(x)\n    return x\n// after\ndef cube_fn(x):\n    return x","handlingStrategy":"validation","validationCode":"const { execSync } = require('child_process');\ntry {\n  execSync('python3 -m py_compile cubes.py', { stdio: 'pipe' });\n} catch (e) {\n  throw new Error('cubes.py has syntax errors; fix before starting Cube');\n}","typeGuard":null,"tryCatchPattern":"try {\n  compiler.compile();\n} catch (e) {\n  if (e instanceof UserError && e.message.startsWith('Python Parsing Error:')) {\n    console.error(e.message); // shows line:column for each error\n    process.exitCode = 1;\n  } else { throw e; }\n}","preventionTips":["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"],"tags":["python","parsing","syntax-error","schema-compiler"],"backgroundTag":"python-syntax-error","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}