{"record":{"id":"536769ac201eaf49","repo":"evanw/esbuild","slug":"missing-kind-in-callname-call","errorCode":null,"errorMessage":"Missing \"kind\" in ${callName}() call","messagePattern":"Missing \"kind\" in (.+?)\\(\\) call","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/shared/common.ts","lineNumber":798,"sourceCode":"        })\n      }\n    }\n    if ((typeof input === 'string' || input instanceof Uint8Array) && input.length > 1024 * 1024) {\n      let next = start\n      start = () => fs.writeFile(input, next)\n    }\n    start(null)\n  }\n\n  let formatMessages: StreamService['formatMessages'] = ({ callName, refs, messages, options, callback }) => {\n    if (!options) throw new Error(`Missing second argument in ${callName}() call`)\n    let keys: OptionKeys = {}\n    let kind = getFlag(options, keys, 'kind', mustBeString)\n    let color = getFlag(options, keys, 'color', mustBeBoolean)\n    let terminalWidth = getFlag(options, keys, 'terminalWidth', mustBeInteger)\n    let logStyle = getFlag(options, keys, 'logStyle', mustBeString)\n    checkForInvalidFlags(options, keys, `in ${callName}() call`)\n    if (kind === void 0) throw new Error(`Missing \"kind\" in ${callName}() call`)\n    if (kind !== 'error' && kind !== 'warning') throw new Error(`Expected \"kind\" to be \"error\" or \"warning\" in ${callName}() call`)\n    let request: protocol.FormatMsgsRequest = {\n      command: 'format-msgs',\n      messages: sanitizeMessages(messages, 'messages', null, '', terminalWidth),\n      isWarning: kind === 'warning',\n    }\n    if (color !== void 0) request.color = color\n    if (terminalWidth !== void 0) request.terminalWidth = terminalWidth\n    if (logStyle !== void 0) request.logStyle = logStyle\n    sendRequest<protocol.FormatMsgsRequest, protocol.FormatMsgsResponse>(refs, request, (error, response) => {\n      if (error) return callback(new Error(error), null)\n      callback(null, response!.messages)\n    })\n  }\n\n  let analyzeMetafile: StreamService['analyzeMetafile'] = ({ callName, refs, metafile, options, callback }) => {\n    if (options === void 0) options = {}\n    let keys: OptionKeys = {}","sourceCodeStart":780,"sourceCodeEnd":816,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/lib/shared/common.ts#L780-L816","documentation":"The options object passed to formatMessages() must include `kind` set to 'error' or 'warning' so esbuild knows how to format the messages. At lib/shared/common.ts:798 the call throws if `kind` is undefined; a further check at line 799 rejects any other string value.","triggerScenarios":"Calling `formatMessages(msgs, { color: true })`, `formatMessages(msgs, { terminalWidth: 80 })`, or any options object omitting `kind`.","commonSituations":"Passing only cosmetic options (color/terminalWidth) and forgetting kind; copy-pasting a partial options object.","solutions":["Add `kind: 'error'` or `kind: 'warning'` to the options object.","Derive kind from the source: use 'error' for result.errors and 'warning' for result.warnings."],"exampleFix":"// before\nconst out = await esbuild.formatMessages(result.errors, { color: true })\n\n// after\nconst out = await esbuild.formatMessages(result.errors, { kind: 'error', color: true })","handlingStrategy":"validation","validationCode":"function safeFormatMessages(msgs, opts) {\n  const kind = opts?.kind === 'error' || opts?.kind === 'warning'\n    ? opts.kind\n    : undefined\n  if (!kind) throw new Error('formatMessages requires options.kind = \"error\" | \"warning\"')\n  return esbuild.formatMessages(msgs, { ...opts, kind })\n}\nawait safeFormatMessages(result.errors, { color: true })","typeGuard":"function isFormatKind(v): v is 'error' | 'warning' {\n  return v === 'error' || v === 'warning'\n}","tryCatchPattern":null,"preventionTips":["Always set options.kind explicitly to 'error' or 'warning'.","Use a wrapper that derives kind from the message source (errors vs warnings).","Treat the options object as required, not optional."],"tags":["api","validation","format-messages"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}