{"record":{"id":"5c3b408d67160031","repo":"the-benchmarker/web-frameworks","slug":"failed-to-parse-app-zl","errorCode":null,"errorMessage":"Failed to parse app.zl","messagePattern":"Failed to parse app\\.zl","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"rust/zeno-rs-actix/src/main.rs","lineNumber":174,"sourceCode":"    let r_post = routes.clone();\n    engine.register(\n        \"http.post\",\n        Arc::new(move |_, _, node, _| {\n            let raw = node.value.clone().unwrap_or_default().trim().to_string();\n            let clean = if raw.starts_with('\\'') || raw.starts_with('\"') {\n                raw[1..raw.len() - 1].to_string()\n            } else {\n                raw\n            };\n            r_post.lock().unwrap().push((\"POST\".to_string(), clean, node.clone()));\n            Ok(())\n        }),\n        empty_slot_meta(),\n    );\n\n    let zl_content = std::fs::read_to_string(\"app.zl\")\n        .unwrap_or_else(|_| include_str!(\"../app.zl\").to_string());\n    let main_node = parse_string(&zl_content, \"app.zl\").expect(\"Failed to parse app.zl\");\n\n    let parent_scope = Scope::new(None);\n    let mut init_ctx = Context::new();\n    let _ = engine.execute(&mut init_ctx, &main_node, &parent_scope);\n\n    let mut route_map: HashMap<String, MethodHandler> = HashMap::new();\n    for (method, path, node) in routes.lock().unwrap().drain(..) {\n        let matchit_path = convert_path_to_matchit(&path);\n        println!(\"Registered route: {} {} -> matchit: {}\", method, path, matchit_path);\n        let entry = route_map\n            .entry(matchit_path)\n            .or_insert(MethodHandler { get: None, post: None });\n        if method == \"GET\" {\n            entry.get = Some(node);\n        } else if method == \"POST\" {\n            entry.post = Some(node);\n        }\n    }","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/the-benchmarker/web-frameworks/blob/3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2/rust/zeno-rs-actix/src/main.rs#L156-L192","documentation":"zeno-rs-actix's main loads app.zl (from disk, falling back to the copy compiled in via include_str!) and parses it with parse_string; the .expect panics with \"Failed to parse app.zl\" if the Zeno DSL source is syntactically invalid, aborting server startup before the route map can be built.","triggerScenarios":"Running the actix server binary when app.zl in the working directory (or the bundled ../app.zl fallback) contains DSL syntax errors, or when the file is read successfully but parse_string returns an Err for the 'app.zl' source name.","commonSituations":"A developer hand-edited app.zl and introduced a syntax error; an incomplete merge left the file malformed; the wrong app.zl was copied into the container working directory, shadowing a valid build-time one; DSL grammar changed in a library upgrade so older .zl files no longer parse.","solutions":["Run the parser/CLI directly on app.zl to get the line/column of the syntax error and fix the DSL source","Diff app.zl against the last known-good version (git diff) to spot accidental edits or merge remnants","If a stale app.zl sits in the working directory, delete or fix it so the valid include_str! fallback is not shadowed by a broken file","After upgrading the engine crate, update app.zl to the current DSL grammar","Temporarily replace expect with error propagation/logging that prints the parse diagnostic before exiting"],"exampleFix":"// before\nlet main_node = parse_string(&zl_content, \"app.zl\").expect(\"Failed to parse app.zl\");\n\n// after\nlet main_node = parse_string(&zl_content, \"app.zl\")\n    .unwrap_or_else(|e| {\n        eprintln!(\"app.zl parse error: {e}\");\n        std::process::exit(1);\n    });","handlingStrategy":"validation","validationCode":"// before starting the server, syntax-check app.zl\nmatch std::fs::read_to_string(\"app.zl\")\n    .or_else(|_| Ok::<_, std::io::Error>(include_str!(\"../app.zl\").to_string()))\n{\n    Ok(content) => {\n        if let Err(e) = zeno::parse_string(&content, \"app.zl\") {\n            eprintln!(\"app.zl is invalid, refusing to start: {e:?}\");\n            std::process::exit(1);\n        }\n    }\n    Err(e) => {\n        eprintln!(\"cannot read app.zl: {e}\");\n        std::process::exit(1);\n    }\n}","typeGuard":"null","tryCatchPattern":"// main panics on parse failure; if embedding, isolate the parse step\nlet main_node = match std::panic::catch_unwind(|| parse_string(&zl_content, \"app.zl\")) {\n    Ok(Ok(node)) => node,\n    Ok(Err(e)) => { eprintln!(\"app.zl parse error: {e:?}\"); std::process::exit(1); }\n    Err(_) => { eprintln!(\"parser panicked while parsing app.zl\"); std::process::exit(1); }\n};","preventionTips":["Add a CI step that parses app.zl on every commit","Validate app.zl after merges and before building deploy images","Keep app.zl under version control and review all edits to it","After engine upgrades, re-validate app.zl against the new DSL grammar","Prefer a validated baked-in app.zl over an unvetted file dropped into the runtime directory"],"tags":["rust","actix","parser","startup","dsl"],"backgroundTag":"dsl-parse-failed","analyzedSha":"3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2","analyzedAt":"2026-09-15T02:39:22.409Z","contentChangedAt":"2026-09-15T02:39:22.409Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}