BoundaryML/baml · error
project name `{name}` contains invalid character(s) {bad:?}.
Error message
project name `{name}` contains invalid character(s) {bad:?}. Use ASCII letters, digits, `-`, `_`, or `.`. What it means
validate_project_name rejects names containing characters outside the whitelist of ASCII letters, digits, `-`, `_`, `.`. The name is interpolated into a quoted TOML string in baml.toml, so characters like `"` or control characters would produce an unparseable manifest; the check reports the exact offending characters.
Source
Thrown at baml_language/crates/baml_cli/src/init_command.rs:177
.and_then(|s| s.to_str())
.filter(|s| !s.is_empty())
.map(|s| s.to_string())
}
/// Cargo-style project-name rules: non-empty, ASCII alphanumeric plus
/// `-`, `_`, `.`. Whitelist beats blacklist here — `render_baml_toml`
/// drops the name straight into a `"..."` TOML string, so a stray `"`
/// (or any control char) in the name produces an unparseable manifest.
fn validate_project_name(name: &str) -> Result<()> {
if name.is_empty() {
anyhow::bail!("project name cannot be empty");
}
let bad: Vec<char> = name
.chars()
.filter(|c| !(c.is_ascii_alphanumeric() || matches!(c, '-' | '_' | '.')))
.collect();
if !bad.is_empty() {
anyhow::bail!(
"project name `{name}` contains invalid character(s) {bad:?}. \
Use ASCII letters, digits, `-`, `_`, or `.`."
);
}
Ok(())
}
fn render_baml_toml(name: &str) -> String {
format!(
r#"[package]
name = "{name}"
# [scripts]
# dev = "-f main"
# Add a client generator, then generate its SDK:
# baml generate add python/pydantic2
# baml generateView on GitHub (pinned to bd85ce9dee)
Solutions
- Rename using only ASCII letters, digits, `-`, `_`, `.` (e.g. `my-cool-app`).
- Put a human-friendly description elsewhere (e.g. edit baml.toml comments after init) instead of encoding it in the name.
- Sanitize the name in your script: strip or replace invalid characters before invoking `baml init`.
Example fix
// before baml init ./app --name "My App!" // after baml init ./app --name "my-app"
Defensive patterns
Strategy: validation
Validate before calling
# guard: enforce Cargo-style name before init
echo "$NAME" | grep -qE '^[A-Za-z0-9._-]+$' || { echo "invalid project name: $NAME"; exit 1; } Prevention
- Restrict names to [A-Za-z0-9._-]
- Sanitize user-supplied names before passing --name
- Keep display names out of the identifier (edit baml.toml later)
When it happens
Trigger: Run `baml init <path> --name` with a name containing spaces, slashes, quotes, unicode, or other non-whitelisted characters.
Common situations: Using a package display name like "My Cool App!", a path fragment like `a/b`, or copying a name with quotes into `--name`.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- project name cannot be empty
- unknown feedback field(s) {}; only "title" and "description"
- feedback field "{key}" must be a string
- feedback needs a title; pass --title "..." or a JSON payload
- feedback payload must be a JSON object like {"title": "..."}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/f1afcbd2e3db2aeb.
Report an issue: GitHub.