From 16822ff84ee14561576572780e3f8662b92e5458 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Mon, 5 Jun 2023 14:39:55 -0500 Subject: [PATCH] cli: Prevent weird `rad issue open` behavior Verify special YAML strings '~' and 'null' are filtered out when processing the input from the editor. Serde replaces empty strings with their values causing an empty title to become '~'. Best to avoid them entirely and be transparent about it. The solution is not meant to be long term. This editor format for getting issue data will be replaced in the near term. --- radicle-cli/src/commands/issue.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/radicle-cli/src/commands/issue.rs b/radicle-cli/src/commands/issue.rs index c6675d12..67e86b44 100644 --- a/radicle-cli/src/commands/issue.rs +++ b/radicle-cli/src/commands/issue.rs @@ -507,10 +507,12 @@ fn prompt_issue( serde_yaml::from_str(&meta).context("failed to parse yaml front-matter")?; meta.title = meta.title.trim().to_string(); - if meta.title.is_empty() { + if meta.title.is_empty() || meta.title == "~" || meta.title == "null" { + // '~' and 'null' are YAML's string values for null and unexpectedly replace empty fields + // for String. return Err(io::Error::new( io::ErrorKind::InvalidInput, - "an issue title must be provided", + "an issue title must be provided and may not be '~' or 'null'", ) .into()); }