jdx/mise · error
invalid tap formula name
Error message
invalid tap formula name '{name}' What it means
Before fetching and evaluating a tap formula/cask, validate_name checks that the requested name is a single safe path component: non-empty, no slashes/backslashes/NULs, not '.' or '..', and exactly one PathBuf component. This prevents path traversal and malformed lookups in the tap tree.
Solutions
- Pass only the bare formula/cask name, e.g. 'wget', not a path
- Strip owner/tap and version qualifiers from the name before calling
- Sanitize/validate user-supplied names against a single-component pattern
Example fix
// before formula_from_ruby(owner, tap, "extra/wget", ...) // after formula_from_ruby(owner, tap, "wget", ...)
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_tap_name(name: &str) -> bool {
!name.is_empty()
&& !name.contains(['/', '\\', '\0'])
&& name != "."
&& name != ".."
&& std::path::PathBuf::from(name).components().count() == 1
} Type guard
fn tap_name(name: &str) -> Option<&str> {
(!name.is_empty()
&& !name.contains(['/', '\\', '\0'])
&& name != "."
&& name != ".."
&& std::path::PathBuf::from(name).components().count() == 1)
.then_some(name)
} Prevention
- Always pass bare formula names, never paths like owner/repo/formula
- Sanitize user-provided names before constructing package requests
When it happens
Trigger: formula_from_ruby or cask_from_ruby is called with a name containing '/', '\\', '\0', equal to '.' or '..', empty, or one that resolves to multiple path components (e.g. 'foo/bar' or a name with a drive/component prefix).
Common situations: Passing 'owner/repo/formula' instead of just the formula name; names derived from untrusted user input or URL fragments; accidental '.'/'..' in generated requests.
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.
Related errors
- brew-cask: command_wrapper requires a command name without…
- app target is outside an allowed Applications directory
- artifact target has changed
- binary target is not an owned Caskroom symlink
- bootstrap_command returned an unsafe mise path
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/c743010e65aebd84.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/tap.rs:364
];
let mut last_error = None;
for path in paths {
match HTTP_FETCH.get_text(format!("{raw_base}/{path}")).await {
Ok(source) => return Ok((source, path)),
Err(err) => last_error = Some(err),
}
}
Err(last_error.unwrap()).wrap_err_with(|| format!("tap has no {directory}/{name}.rb"))
}
fn validate_name(name: &str) -> Result<()> {
if name.is_empty()
|| name.contains(['/', '\\', '\0'])
|| name == "."
|| name == ".."
|| PathBuf::from(name).components().count() != 1
{
bail!("invalid tap formula name '{name}'");
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
async fn test_ruby() -> Result<Option<PathBuf>> {
if let Some(ruby) = usable_system_ruby().await {
return Ok(Some(ruby));
}
super::super::source::installed_ruby_bin().await
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[tokio::test]
async fn ignores_mise_shim_when_selecting_system_ruby() -> Result<()> {View on GitHub (pinned to 533346cc37)