feat(connections): Add connection command to list/view/create connections via the CLI#6
feat(connections): Add connection command to list/view/create connections via the CLI#6
Conversation
| if let Some(one_of) = schema["oneOf"].as_array() { | ||
| let titles: Vec<String> = one_of | ||
| .iter() | ||
| .filter_map(|v| v["title"].as_str().map(str::to_string)) |
There was a problem hiding this comment.
P1 — wrong walker used for auth oneOf variants
walk_properties doesn't handle const fields — they'll be prompted as regular text inputs instead of being auto-injected. Auth oneOf variants commonly use a const discriminator field (e.g. "type": {"const": "password_auth"}). Using walk_properties here will either prompt the user for a field they shouldn't be touching, or silently omit the discriminator if the user leaves it blank.
| .filter_map(|v| v["title"].as_str().map(str::to_string)) | |
| return walk_variant(&one_of[idx]); |
There was a problem hiding this comment.
Review
Issues
P1 — src/connections_new.rs:243
walk_auth calls walk_properties instead of walk_variant when walking the selected oneOf auth variant. walk_properties has no special handling for const-valued fields — they get prompted as plain text inputs rather than auto-injected. Auth oneOf variants commonly use a const discriminator (e.g. "type": {"const": "password_auth"}), so this will either confuse the user with a nonsensical prompt or silently drop the discriminator from the request body, causing the API to reject the connection.
Fix: change walk_properties(&one_of[idx]) to walk_variant(&one_of[idx]).
Action Required
Fix the walk_auth call on line 243 of src/connections_new.rs before merging.
| .with_default(default) | ||
| .prompt() | ||
| .unwrap_or_else(|_| std::process::exit(0)); | ||
| Some(Value::Bool(val)) |
There was a problem hiding this comment.
The ("boolean", _) arm ignores is_required — optional boolean fields are always included in the config payload. If the user just wants the API default, there's no way to skip them. Consider using Option<bool> semantics: for optional fields, show a three-way select (true / false / skip) or check is_required before always returning Some.
| Some(Value::Bool(val)) | |
| Some(Value::Bool(val)) | |
| } |
Alternatively, wrap the return so optional booleans can produce None:
if !is_required {
// Confirm doesn't support "skip", so prompt but allow skipping via a separate check if needed
}| // Phase 3: Connection name | ||
| let conn_name = Text::new("Connection name:") | ||
| .prompt() | ||
| .unwrap_or_else(|_| std::process::exit(0)); |
There was a problem hiding this comment.
No validation that the connection name is non-empty. An empty name will silently reach the API and produce an opaque error response. Add a validator:
| .unwrap_or_else(|_| std::process::exit(0)); | |
| let conn_name = Text::new("Connection name:") | |
| .with_validator(|input: &str| { | |
| if input.trim().is_empty() { | |
| Ok(inquire::validator::Validation::Invalid("Connection name cannot be empty".into())) | |
| } else { | |
| Ok(inquire::validator::Validation::Valid) | |
| } | |
| }) | |
| .prompt() | |
| .unwrap_or_else(|_| std::process::exit(0)); |
| } | ||
| } | ||
|
|
||
| _ => None, |
There was a problem hiding this comment.
The catch-all _ => None silently skips any field type not explicitly handled (e.g. "number" for floats). If a connection type schema includes a number field, it will be omitted from the submitted config without any user-visible indication, likely producing a confusing API error. Consider logging an eprintln! warning here so it's visible during development, or add a "number" arm alongside "integer".
No description provided.