quickwit-oss/quickwit · error

time format description should be valid

Error message

time format description should be valid

What it means

This panic fires when `time::format_description::parse_borrowed::<2>` fails to parse the hard-coded format string `[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]Z` used by the telemetry log timestamp formatter. The string is a compile-time constant in the source, so the panic can only occur if that constant was edited to an invalid format description (bad component syntax, invalid modifier, or exceeding the 2-item inline capacity... note the string parses as one item, so capacity is not the issue). It protects the logging subsystem from silently emitting malformed timestamps.

Solutions

  1. Check git history of quickwit/quickwit-telemetry-exporters/src/logs.rs — restore the original format string `[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]Z`
  2. Validate your new format string with `time::format_description::parse_borrowed::<2>(...)` in a unit test before committing it
  3. If a `time` crate upgrade broke it, consult the time-rs changelog for renamed/removed format components and fix the description accordingly
  4. Use `time::macros::format_description!` instead of runtime parsing to turn this panic into a compile-time error

Example fix

// before (invalid component)
"[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:three]Z"
// after
"[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]Z"
Defensive patterns

Strategy: validation

Validate before calling

#[test]
fn time_format_is_valid() {
    time::format_description::parse_borrowed::<2>(
        "[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]Z",
    ).expect("time format description should be valid");
}

Prevention

When it happens

Trigger: Calling `time_formatter()` (directly, or via `get_from_env`/`capture_full_log` which configure the tracing subscriber) after someone modified the format string literal in quickwit-telemetry-exporters/src/logs.rs to an invalid `time` crate format description.

Common situations: A contributor edits the timestamp format to change precision or timezone representation and uses invalid `time`-crate syntax (e.g. `[subsecond digits:9]` misspelled, unknown component, wrong modifier); upgrading the `time` crate to a version that removed or renamed a format component.

Related errors


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/05a05efe2201a3f8. Report an issue: GitHub.

Appendix: source

Thrown at quickwit/quickwit-telemetry-exporters/src/logs.rs:36

use serde_json::{Map, Value};
use time::format_description::BorrowedFormatItem;
use tracing::field::{Field, Visit};
use tracing::{Event, Subscriber};
use tracing_subscriber::field::RecordFields;
use tracing_subscriber::fmt::FmtContext;
use tracing_subscriber::fmt::format::{
    DefaultFields, Format, FormatEvent, FormatFields, Full, Json, JsonFields, Writer,
};
use tracing_subscriber::fmt::time::UtcTime;
use tracing_subscriber::registry::LookupSpan;

/// We do not rely on the RFC3339 implementation, because it has a nanosecond precision.
/// See discussion here: https://github.com/time-rs/time/discussions/418
pub(crate) fn time_formatter() -> UtcTime<Vec<BorrowedFormatItem<'static>>> {
    let time_format = time::format_description::parse_borrowed::<2>(
        "[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]Z",
    )
    .expect("time format description should be valid");
    UtcTime::new(time_format)
}

pub(crate) enum EventFormat<'a> {
    Full(Format<Full, UtcTime<Vec<BorrowedFormatItem<'a>>>>),
    Json(Format<Json>),
    Ddg(DdgFormat),
}

impl EventFormat<'_> {
    /// Gets the log format from the environment variable `QW_LOG_FORMAT`.
    pub(crate) fn get_from_env() -> Self {
        match get_from_env_opt::<String>("QW_LOG_FORMAT", false)
            .as_deref()
            .map(str::to_ascii_lowercase)
            .as_deref()
        {
            Some("json") => EventFormat::Json(tracing_subscriber::fmt::format().json()),

View on GitHub (pinned to a39730c5cd)