jdx/mise · error

workspace ID cannot be empty

Error message

workspace {kind} ID cannot be empty

What it means

This error is thrown by `validate_id_part` in src/task/workspace.rs when an identifier component (provider or project) of a workspace ID is an empty string. Workspace project IDs are namespaced like `provider:local`, and every part must be non-empty to keep IDs unambiguous. The library fails fast instead of creating a workspace entry with an unusable ID.

Solutions

  1. Provide a non-empty provider and project ID when constructing the workspace project
  2. Check the workspace config file / provider metadata for a missing or empty name field
  3. If an env var feeds the ID, verify it is actually set before use

Example fix

// before
let project = WorkspaceProject::new(provider, "");
// after
let project = WorkspaceProject::new(provider, "api-server");
Defensive patterns

Strategy: validation

Validate before calling

if provider.is_empty() || local_id.is_empty() {
    return Err(anyhow!("workspace provider/project ID must be non-empty"));
}
let project = WorkspaceProject::new(provider, local_id)?;

Type guard

fn is_valid_id_part(s: &str) -> bool { !s.is_empty() && s.trim() == s && !s.chars().any(char::is_control) }

Try / catch

match WorkspaceProject::new(provider, local_id) {
    Ok(p) => p,
    Err(e) if e.to_string().contains("cannot be empty") => { /* supply a real ID or skip */ }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `WorkspaceProject::new(provider, local_id)` (or a provider's `collect_provider_projects`) with an empty provider name or empty local project ID, e.g. from an empty key/value in workspace config metadata.

Common situations: A `[workspace]` TOML section or provider metadata omits the project name; an environment variable or config key resolves to empty; a provider plugin returns a project with an unset ID field.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/62dd66dd8fe9e127. Report an issue: GitHub.

Appendix: source

Thrown at src/task/workspace.rs:65

    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        Display::fmt(&self.0, f)
    }
}

impl FromStr for ProjectId {
    type Err = eyre::Report;

    fn from_str(value: &str) -> Result<Self> {
        let Some((provider, local_id)) = value.split_once(':') else {
            bail!("workspace project ID {value:?} must include a provider namespace");
        };
        Self::new(provider, local_id)
    }
}

fn validate_id_part(kind: &str, value: &str) -> Result<()> {
    if value.is_empty() {
        bail!("workspace {kind} ID cannot be empty");
    }
    if value.trim() != value || value.chars().any(char::is_control) {
        bail!(
            "workspace {kind} ID {value:?} contains surrounding whitespace or control characters"
        );
    }
    if kind == "provider" && value.contains(':') {
        bail!("workspace provider ID {value:?} cannot contain ':'");
    }
    Ok(())
}

/// A project discovered from ecosystem-specific workspace metadata.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub(crate) struct WorkspaceProject {
    /// Stable identity used by dependency edges and task scoping.
    pub id: ProjectId,
    /// Normalized path relative to the workspace root. `.` represents the root.

View on GitHub (pinned to 533346cc37)