neoclide/coc.nvim · error

Unexpected messageDialogKind: ${this.messageDialogKind}

Error message

Unexpected messageDialogKind: ${this.messageDialogKind}

What it means

coc's message display behavior is driven by configured kinds (messageDialogKind / messageReportKind). _showMessage switches on the configured dialog kind ('dialog', 'confirm', 'notification', etc.); an unrecognized value falls through to the default branch and throws, since the config value is outside the supported set.

Source

Thrown at src/core/notifications.ts:108

    let msgDialogKind = this.messageDialogKind
    if (this.enableMessageDialog === true) {
      // maintain backwards compatibility, with the original implementation, set the default message kind to use
      // notification interface even when action items are present.
      msgDialogKind = 'notification'
    }
    if (items.length > 0) {
      switch (msgDialogKind) {
        case 'confirm':
          return await this.showConfirm(message, items, kind)
        case 'menu':
          return await this.showMenuPicker(`Choose an action`, message, `Coc${kind}Float`, items)
        case 'notification': {
          let texts = items.map(o => typeof o === 'string' ? o : o.title)
          let idx = await this.createNotification(kind.toLowerCase() as NotificationKind, message, texts)
          return items[idx]
        }
        default:
          throw new Error(`Unexpected messageDialogKind: ${this.messageDialogKind}`)
      }
    } else {
      // by default the report kind will be echo, meaning that we still keep backwards compatibility with the original
      // behavior where the user expects that messages are printed to the echo area, with the added caveat that all
      // message kinds will go there now, information, warning or error
      let msgReportKind = this.messageReportKind
      switch (msgReportKind) {
        case 'echo': {
          let msgType: MsgTypes = kind == 'Info' ? 'more' : kind == 'Error' ? 'error' : 'warning'
          this.echoMessages(message, msgType)
          break
        }
        case 'notification': {
          await this.createNotification(kind.toLowerCase() as NotificationKind, message, [])
          break
        }
        default:
          throw new Error(`Unexpected messageReportKind: ${msgReportKind}`)

View on GitHub (pinned to 50e974d969)

Solutions

  1. Reset the messageDialogKind configuration to a supported value ('dialog', 'confirm', 'notification')
  2. Fix the typo in coc-settings.json or the setting source
  3. Remove the custom setting to fall back to defaults
  4. Validate configuration values at load time in your setup scripts

Example fix

// before (coc-settings.json)
"notification.messageDialogKind": "popups"
// after
"notification.messageDialogKind": "notification"
Defensive patterns

Strategy: validation

Validate before calling

const allowed = ['dialog','confirm','notification']
const kind = config.notification?.messageDialogKind
if (kind && !allowed.includes(kind)) throw new Error(`messageDialogKind must be one of ${allowed}`)

Type guard

const isDialogKind = (v): v is 'dialog'|'confirm'|'notification' =>
  v === 'dialog' || v === 'confirm' || v === 'notification'

Try / catch

try {
  await notifications.showMessage('error', msg)
} catch (e) {
  if (String(e.message).includes('messageDialogKind')) notify(`Fix notification.messageDialogKind in your settings`)
  else throw e
}

Prevention

When it happens

Trigger: Setting 'notification.messageDialogKind' (or the equivalent configuration) to a string other than the supported values, e.g. a typo like 'notifcation' or an arbitrary string, then triggering a message display.

Common situations: Hand-edited coc-settings.json with an invalid enum value; config migrated from older coc versions where allowed values differed; programmatic configuration setting a wrong literal.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31). Data as JSON: /api/errors/dd295dc437b3f181. Report an issue: GitHub.