{"record":{"id":"7b532490c9f947f5","repo":"windmill-labs/windmill","slug":"error-parsing-code","errorCode":null,"errorMessage":"Error parsing code: {}","messagePattern":"Error parsing code: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-php/src/lib.rs","lineNumber":52,"sourceCode":"            },\n            Literal::Float(f) => match f.value.to_string().parse() {\n                Ok(i) => Some(Value::Number(i)),\n                Err(_) => None,\n            },\n        },\n        Expression::Bool(b) => Some(Value::Bool(b.value)),\n        _ => None,\n    }\n}\n\npub fn parse_php_signature(\n    code: &str,\n    override_entrypoint: Option<String>,\n) -> anyhow::Result<MainArgSignature> {\n    let entrypoint_fn_name = override_entrypoint.unwrap_or(\"main\".to_string());\n\n    let ast = parser::parse(code)\n        .map_err(|e| anyhow::anyhow!(\"Error parsing code: {}\", e.to_string()))?;\n\n    let mut entrypoint_params = None;\n    let mut has_preprocessor = None;\n    for node in ast.into_iter() {\n        match node {\n            Statement::Function(FunctionStatement {\n                name,\n                parameters: FunctionParameterList { parameters, .. },\n                ..\n            }) => {\n                let fn_name = name.to_string();\n\n                if has_preprocessor.is_none() && fn_name == \"preprocessor\" {\n                    has_preprocessor = Some(true);\n                }\n\n                if entrypoint_params.is_none() && fn_name == entrypoint_fn_name {\n                    entrypoint_params = Some(parameters);","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-php/src/lib.rs#L34-L70","documentation":"parse_php_signature parses the whole PHP file with the php-parser crate before scanning for the entrypoint function (default 'main'). Any syntax error the underlying PHP parser reports — message included via {} — is rethrown as 'Error parsing code: ...'.","triggerScenarios":"Calling parse_php_signature with code containing PHP syntax errors: unterminated strings, missing semicolons, unclosed braces, PHP version-incompatible syntax (e.g. enums on PHP 7), or non-PHP content passed as code.","commonSituations":"Deploying a script written for a newer PHP version than the embedded parser supports; a copy-pasted snippet with template placeholders ({{ ... }}) left in; files mixing HTML with PHP where the pure-PHP parser chokes.","solutions":["Read the wrapped message after 'Error parsing code:' — it names the exact line/column of the PHP syntax error.","Fix the syntax error at the reported location in the PHP file.","Remove non-PHP content (HTML blocks, templating placeholders) or ensure the file is a valid .php script the parser accepts.","Verify the syntax with 'php -l file.php' locally; the windmill parser tracks the same grammar family.","Check that syntax features used (enums, readonly, named args) match the PHP version the parser supports."],"exampleFix":"// before\nfunction main($x) {\n  return $x +\n}\n\n// after\nfunction main($x) {\n  return $x + 1;\n}","handlingStrategy":"try-catch","validationCode":"// Validate PHP syntax before parsing (requires php on PATH)\nconst { execSync } = require('child_process');\nfunction validatePhpSyntax(code) {\n  try {\n    execSync('php -l', { input: code, stdio: 'pipe' });\n  } catch (e) {\n    throw new Error('PHP syntax invalid: ' + e.stderr.toString());\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const sig = await parsePhpSignature(code, entrypoint);\n} catch (e) {\n  if (String(e.message).startsWith('Error parsing code:')) {\n    const detail = String(e.message).replace('Error parsing code:', '').trim();\n    throw new Error(`Fix PHP syntax: ${detail}`);\n  }\n  throw e;\n}","preventionTips":["Run 'php -l' locally on every PHP script before deploying","Keep the file pure PHP (no interleaved HTML or template placeholders)","Match PHP language features to the version the parser supports","Strip templating placeholders ({{ }}) before parsing"],"tags":["php","parser","syntax-error"],"backgroundTag":"syntax-error","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}