Skip to content

feat(connections): Add connection command to list/view/create connections via the CLI#6

Merged
pthurlow merged 7 commits intomainfrom
feat/connections
Mar 17, 2026
Merged

feat(connections): Add connection command to list/view/create connections via the CLI#6
pthurlow merged 7 commits intomainfrom
feat/connections

Conversation

@pthurlow
Copy link
Collaborator

No description provided.

claude[bot]

This comment was marked as resolved.

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
.filter_map(|v| v["title"].as_str().map(str::to_string))
return walk_variant(&one_of[idx]);

Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
.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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

@pthurlow pthurlow merged commit ca02e32 into main Mar 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant