zed-industries/zed · error

Invalid directive: {directive}

Error message

Invalid directive: {directive}

What it means

A ZLOG filter directive of the form name=level=extra contains a second '=', so the level string is malformed and cannot be parsed. The filter string given to zlog's env_config parse is syntactically invalid.

Source

Thrown at crates/zlog/src/env_config.rs:17

use anyhow::Result;

pub struct EnvFilter {
    pub level_global: Option<log::LevelFilter>,
    pub directive_names: Vec<String>,
    pub directive_levels: Vec<log::LevelFilter>,
}

pub fn parse(filter: &str) -> Result<EnvFilter> {
    let mut max_level = None;
    let mut directive_names = Vec::new();
    let mut directive_levels = Vec::new();

    for directive in filter.split(',') {
        match directive.split_once('=') {
            Some((name, level)) => {
                anyhow::ensure!(!level.contains('='), "Invalid directive: {directive}");
                let level = parse_level(level.trim())?;
                directive_names.push(name.trim().trim_end_matches(".rs").to_string());
                directive_levels.push(level);
            }
            None => {
                let Ok(level) = parse_level(directive.trim()) else {
                    directive_names.push(directive.trim().trim_end_matches(".rs").to_string());
                    directive_levels.push(log::LevelFilter::max() /* Enable all levels */);
                    continue;
                };
                anyhow::ensure!(max_level.is_none(), "Cannot set multiple max levels");
                max_level.replace(level);
            }
        };
    }

    Ok(EnvFilter {
        level_global: max_level,

View on GitHub (pinned to f4178619ac)

Solutions

  1. Fix the directive to the form module=level (e.g. 'my_module=debug')
  2. Validate user-supplied filter strings before passing them to parse and surface a clear message
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zlog/src/env_config.rs:17 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/dcba10df7c32760d. Report an issue: GitHub.