git-ents.gitmain
⌘K
foforge
commit f8db57d
fix: avoid figue crash parsing zero CLI args in git-ents-server

Fly.io runs the image with no CLI tokens at all (every setting arrives via env vars, read manually in run/serve). figue’s flatten support reports the all-Option Args group as a missing field rather than an all-None value when nothing on the command line matches any of its keys, so the binary crash-looped on every boot and any new deploy failed its health check the same way.

fixes: server crash-looping on boot with zero CLI args Assisted-by: Claude:claude-sonnet-5

Joseph D. Carpinelli · 1 month ago

Reviews

No reviews of this commit yet — record a verdict below.

Start a review

verdict

crates/git-ents-server/src/main.rs @@ -15,6 +15,25 @@ } fn main() -> ExitCode { + let raw_args: Vec<String> = std::env::args().skip(1).collect(); + + // With zero CLI tokens (how Fly.io always runs this image — every setting + // arrives via env vars, which `git_ents_server::run` reads itself), + // `#[facet(flatten)]`'s all-`Option` `args` never gets a single populated + // key, and figue reports the whole flattened group as a missing field + // rather than an all-`None` value. Build it directly instead of parsing. + if raw_args.is_empty() { + return git_ents_server::run(git_ents_server::Args { + command: None, + port: None, + data_dir: None, + cert_nonce_seed: None, + hooks_dir: None, + web_signing_key: None, + checks_queue: None, + }); + } + let config = match figue::builder::<Cli>() { Ok(builder) => builder, Err(error) => { @@ -22,7 +41,7 @@ return ExitCode::FAILURE; } } - .cli(|cli| cli.args(std::env::args().skip(1))) + .cli(|cli| cli.args(raw_args)) .help(|help| { help.program_name("git-ents-server") .version(env!("CARGO_PKG_VERSION"))