oxc-project/oxc · error

Rule name must be present for rule diagnostics

Error message

Rule name must be present for rule diagnostics

What it means

Runtime panic path in tsgolint.rs while converting a tsgolint diagnostic message: the payload was typed as a Rule diagnostic but its rule field was absent, so the .expect() guard aborts. It indicates the tsgolint binary sent malformed diagnostic JSON missing the rule name.

Source

Thrown at crates/oxc_linter/src/tsgolint.rs:1276

    let payload_str = String::from_utf8_lossy(&payload_bytes);

    match message_type {
        MessageType::Error => {
            let error_payload = serde_json::from_str::<TsGoLintErrorPayload>(&payload_str)
                .map_err(TsGoLintMessageParseError::InvalidErrorPayload)?;

            Ok(TsGoLintMessage::Error(TsGoLintError { error: error_payload.error }))
        }
        MessageType::Diagnostic => {
            let diagnostic_payload =
                serde_json::from_str::<TsGoLintDiagnosticPayload>(&payload_str)
                    .map_err(TsGoLintMessageParseError::InvalidDiagnosticPayload)?;

            Ok(TsGoLintMessage::Diagnostic(match diagnostic_payload.kind {
                DiagnosticKind::Rule => TsGoLintDiagnostic::Rule(TsGoLintRuleDiagnostic {
                    rule: diagnostic_payload
                        .rule
                        .expect("Rule name must be present for rule diagnostics"),
                    span: diagnostic_payload.range.map_or_else(
                        || {
                            debug_assert!(false, "Range must be present for rule diagnostics");
                            Span::default()
                        },
                        |range| Span::new(range.pos, range.end),
                    ),
                    message: diagnostic_payload.message,
                    fixes: diagnostic_payload.fixes,
                    suggestions: diagnostic_payload.suggestions,
                    labeled_ranges: diagnostic_payload.labeled_ranges,
                    file_path: PathBuf::from(
                        diagnostic_payload
                            .file_path
                            .expect("File path must be present for rule diagnostics"),
                    ),
                }),
                DiagnosticKind::Internal => {

View on GitHub (pinned to a3d33dda7c)

Solutions

  1. Ensure tsgolint always includes a rule name in rule diagnostic payloads
  2. Update the pinned tsgolint version if a newer one fixes the payload format
  3. Check the protocol handshake so non-rule diagnostics are not decoded as Rule kind
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/oxc_linter/src/tsgolint.rs:1276 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@a3d33dda7c (2026-08-20). Data as JSON: /api/errors/a0e7bdc3ffc17f60. Report an issue: GitHub.