vectordotdev/vector · info

Could not convert concurrency to JSON

Error message

Could not convert concurrency to JSON

What it means

This panic fires in `Concurrency::to_value()` when `serde_json::to_value(self)` fails. `Concurrency` serializes to a plain string enum (or number), which JSON can always represent, so serialization is infallible by construction and the expect asserts that.

Solutions

  1. Report as a bug to Vector if observed after a version upgrade.
  2. Check that any custom-patched Concurrency serialization still emits JSON-compatible values.
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: Converting a `Concurrency` value to a JSON `Value` (e.g. for config templating/health dump output); panic requires serde_json to reject a plain enum serialization, which cannot happen.

Common situations: Not reachable in normal operation; would only appear if the Concurrency Serialize impl were changed to emit non-JSON-representable data (e.g. maps with non-string keys).

Understand the failure class

Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/f9c30376ffcfb26c. Report an issue: GitHub.

Appendix: source

Thrown at src/sinks/util/service/concurrency.rs:164

        let mut fixed_schema = generate_number_schema::<usize>();
        let mut fixed_metadata =
            Metadata::with_description("A fixed amount of concurrency will be allowed.");
        fixed_metadata.set_transparent();
        fixed_metadata.add_custom_attribute(CustomAttribute::kv("docs::numeric_type", "uint"));
        fixed_metadata.add_custom_attribute(CustomAttribute::kv("logical_name", "Fixed"));
        apply_metadata(&mut fixed_schema, fixed_metadata);

        Ok(generate_one_of_schema(&[
            none_schema,
            adaptive_schema,
            fixed_schema,
        ]))
    }
}

impl ToValue for Concurrency {
    fn to_value(&self) -> Value {
        serde_json::to_value(self).expect("Could not convert concurrency to JSON")
    }
}

#[test]
fn is_serialization_reversible() {
    let variants = [
        Concurrency::None,
        Concurrency::Adaptive,
        Concurrency::Fixed(8),
    ];

    for v in variants {
        let value = serde_json::to_value(v).unwrap();
        let deserialized = serde_json::from_value::<Concurrency>(value)
            .expect("Failed to deserialize a previously serialized Concurrency value");

        assert_eq!(v, deserialized)
    }

View on GitHub (pinned to bdb87aeaa4)