Skip to content

fix(cli): validate node name in dora new --kind node - #2849

Merged
trunk-io[bot] merged 1 commit into
mainfrom
claude/dreamy-bardeen-90d0pc-new-node-name-validation
Jul 28, 2026
Merged

fix(cli): validate node name in dora new --kind node#2849
trunk-io[bot] merged 1 commit into
mainfrom
claude/dreamy-bardeen-90d0pc-new-node-name-validation

Conversation

@phil-opp

Copy link
Copy Markdown
Collaborator

Issue

create_dataflow rejects names containing / or non-ASCII characters, but the --kind node path (create_custom_node) had no such guard. It built directories straight from the raw name via the non-recursive fs::create_dir, so:

dora new --lang python --kind node a/b

failed with a confusing "failed to create root directory" (or, if a already existed, silently created a nested path the user didn't intend). Non-ASCII names were likewise unvalidated.

Fix

Apply the same contains('/') / is_ascii() checks that create_dataflow already uses, with clear error messages. Spaces remain allowed — they're normalized to -/_ — so the internal create_dataflow callers ("talker 1", "listener 1", …) are unaffected.

Validation

  • cargo build -p dora-cli, cargo clippy ... -D warnings, and cargo fmt --all --check pass.
  • The dora new --kind dataflow template path still generates its custom nodes (its calls use space-separated ASCII names, which pass validation).

⚠️ This PR is machine-generated by Claude (Claude Code), an AI assistant. Please review carefully before merging.

🤖 Generated with Claude Code

https://claude.ai/code/session_01D2eu6P1CvTvoKdK9fK3ZSd


Generated by Claude Code

`create_dataflow` rejects names containing `/` or non-ASCII characters, but
the `--kind node` path (`create_custom_node`) had no such guard. It built
directories straight from the raw name via the non-recursive
`fs::create_dir`, so `dora new --lang python --kind node a/b` failed with a
confusing "failed to create root directory" (or silently created a nested
path the user did not intend), and non-ASCII names were unvalidated.

Apply the same `contains('/')` / `is_ascii()` checks used by
`create_dataflow`, with clear error messages. Spaces remain allowed — they
are normalized to `-`/`_` — so the internal `create_dataflow` callers
(`"talker 1"`, `"listener 1"`, ...) are unaffected.

Validation: `cargo build -p dora-cli`, `cargo clippy`, and `cargo fmt
--check` pass; `create_dataflow`'s template generation still succeeds
(its custom-node calls use space-separated ASCII names).

This change was generated by Claude (Claude Code), an AI assistant. It is
machine-generated and should be reviewed carefully before merging.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2eu6P1CvTvoKdK9fK3ZSd
@trunk-io

trunk-io Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

😎 Merged successfully - details.

Copy link
Copy Markdown
Collaborator Author

🤖 Fully automated review by Claude — this review was generated end-to-end by an automated agent with no human vetting. Treat it accordingly.

No issues found. The contains('/') and !is_ascii() guards match the existing create_dataflow validation in the same file, bail is already in scope, and spaces are still allowed (normalized to -/_), so the internal callers that pass names like "talker 1" are unaffected.

One optional, non-blocking note: like create_dataflow, this does not reject a Windows-style \ separator, so dora new --kind node a\b would still create a nested path on Windows — but that matches the existing behavior you're mirroring, so leaving it out is reasonable.


Generated by Claude Code

@phil-opp
phil-opp marked this pull request as ready for review July 28, 2026 10:43
@trunk-io
trunk-io Bot merged commit 6f8de4a into main Jul 28, 2026
27 checks passed
@trunk-io
trunk-io Bot deleted the claude/dreamy-bardeen-90d0pc-new-node-name-validation branch July 28, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants