Skip to content
Reference

Diagnostics

Reference for every Kubb diagnostic code, with its severity, cause, and fix, plus the terminal, agent, and JSON formats Kubb reports them in.

A Kubb diagnostic tells you what went wrong, where in the spec, and how to fix it. Its stable code links to its entry here.

  ✖ Could not find a definition for #/components/schemas/Owner.     KUBB_REF_NOT_FOUND
    at   petStore.yaml:336:17
    fix  Add the schema under `components.schemas`, or fix the `$ref`. Run `kubb validate` to check the spec.
    ↳ Learn more  kubb.dev/docs/5.x/reference/diagnostics#kubb-ref-not-found

A terminal gets the first format. An AI agent, CI, or a pipe gets the second, with the reporting plugin in brackets after the code.

SeverityEffect
ErrorFails the run. kubb generate exits with code 1.
WarningReported. The run continues.
InfoAdvisory. Never fails the run.

To hide a warning or info code, list it in diagnostics.ignore. Errors cannot be hidden.

Diagnostic details covers rarer cases per code.

Crashes

KUBB_ADAPTER_FAILED, KUBB_PARSER_FAILED, KUBB_PLUGIN_FAILED, KUBB_INTERNAL_ERROR, and KUBB_UNKNOWN mark a crash. The agent format, --verbose, and --reporter json show its stack.

Report it with the stack and a spec fragment that reproduces it. Kubb prints a report: link when the extension sets meta.issues.

Errors

KUBB_ADAPTER_FAILED

The adapter crashed while parsing the input.

Fix: Check the input and adapter options, or report the crash.

KUBB_ADAPTER_REQUIRED

@kubb/plugin-redoc runs without the OpenAPI adapter.

Fix: Set adapter: adapterOas() in kubb.config.ts.

KUBB_BARREL_DUPLICATE_EXPORT

Two files in one barrel folder export the same name.

Fix: Rename one declaration, change the resolver, or split the output folders.

KUBB_CLEAN_ROOT

output.path is the project root or a parent of it, so output.clean would delete your source.

Fix: Point output.path at a generated folder such as ./src/gen, or turn off output.clean.

KUBB_CONFIG_EDIT_FAILED

Kubb could not change the config file safely, for example to add, remove, or turn off a plugin.

Fix: Make the change by hand. The message names the edit and why Kubb refused it.

KUBB_CONFIG_FAILED

The config file threw while loading, or exports no configuration.

Fix: Fix the error under caused by:, and export a config or a list of configs.

KUBB_CONFIG_NOT_FOUND

Kubb found no kubb.config.* or .kubbrc.* file in the folder, its .config/ and configs/ folders, or a parent folder, and no --config path was passed.

Fix: Run kubb init, or pass the path with --config.

KUBB_FORMAT_FAILED

The output.format tool failed. Kubb still writes the files.

Fix: Run the formatter on the output folder to see the error.

KUBB_GIT_INPUT_FAILED

A git input is malformed, or git could not fetch it.

Fix: Use git+<repo>#<ref>:<path>, and run git fetch --depth 1 <repo> <ref> to see the git error.

KUBB_INCOMPATIBLE_DEPENDENCY

A configured plugin's meta.version is outside the version range in another plugin's dependencies.

Fix: Install a version of either plugin that fits the range.

KUBB_INCOMPATIBLE_EXTENSION

An extension's meta.compatibility.kubb or .node range excludes the running version.

Fix: Upgrade Kubb or Node.js into the range, or install an extension version that supports yours.

KUBB_INLINE_FAILED

Kubb cannot inline a name imported from an all-inline file, so it skips that file.

Fix: Add an inline definition, register a parser with inline support, or stop marking the source as inline.

KUBB_INPUT_NOT_FOUND

Kubb cannot read the input file or the kubb generate <path> path.

Fix: Check that the file exists and is readable. Relative paths resolve against root.

KUBB_INPUT_REQUEST_FAILED

A URL input or $ref answers with a 4xx or 5xx status.

Fix: Open the URL to see the answer. Kubb sends no credentials, so for a 401 or 403, use a local copy.

KUBB_INPUT_REQUIRED

An adapter is set, but input is empty.

Fix: Set input.

KUBB_INPUT_UNREACHABLE

A URL input, a $ref URL, or the registry never answered.

Fix: Check that the host is up and reachable from this machine, through any VPN or proxy.

KUBB_INSECURE_URL

A URL that gets credentials or installs packages uses plain http:// on another machine, or is an IP address where Kubb needs a hostname.

Fix: Use https://. Plain http:// works only for localhost, 127.0.0.1, or [::1].

KUBB_INTERNAL_ERROR

A bug in Kubb.

Fix: Rerun with --verbose for the stack, then report it on GitHub with the spec and config.

KUBB_INVALID_ARGUMENT

A flag, argument, or environment variable is missing or has a value the command cannot use.

Fix: Pass the value the message asks for. --help lists the flags.

KUBB_INVALID_DOCUMENT

The input has a syntax error, no openapi or swagger version, or a version Kubb cannot upgrade to OpenAPI 3.1.

Fix: Fix the syntax at the reported line, and point input at a Swagger 2.0 or OpenAPI 3.0 to 3.2 spec.

KUBB_INVALID_CONFIG

One of these is wrong, and Kubb stops before it generates:

  • The config file exports something other than a config object or a non-empty array of them, such as null from a config function. The message names the file.
  • The config has no output.path.
  • output.format or output.lint names a tool Kubb does not know, such as 'prettierr'.

Fix: Export defineConfig({ ... }), or a function that returns one. Set output.path, and set output.format and output.lint to 'auto', false, or a tool the message lists.

KUBB_INVALID_PLUGIN_OPTIONS

A plugin's options cannot work as given, such as group or sdk.mode: 'tag' with file output. The message names the case.

Fix: Change what the message names. See Invalid plugin options.

KUBB_INVALID_SERVER_VARIABLE

A server variable resolves to a value outside its enum.

Fix: Pick an enum value in the adapter's server.variables, or fix the spec's default or enum.

KUBB_LEGACY_INPUT

input is a v4 { path } or { data } wrapper.

Fix: Pass the value directly, such as input: './petStore.yaml' or input: spec.

KUBB_LINT_FAILED

The output.lint tool failed. Kubb still writes the files.

Fix: Run the linter on the output folder, and relax its rules for generated files.

KUBB_MISSING_DEPENDENCY

A plugin lists another in dependencies without optional: true, and the config lacks it.

Fix: Install that plugin and add it to plugins.

KUBB_MODULE_NOT_FOUND

A package Kubb or an extension loads at run time is missing, or its installed version does not work.

Fix: Install the package the message names. caused by: shows the load error.

KUBB_MOVED_TO_KIT

Code called a resolver, generator or macro helper from @kubb/core: addGenerator, setResolver, setMacros, addMacro, Resolver, createResolver, defineResolver, defineGenerator or toFilePath. These moved to @kubb/kit. @kubb/kit 5.23.1 still imports them from core, so it reports this error when it loads next to a newer @kubb/core. The deprecated ctx.driver.getResolver(name) also reports it when the plugin has no resolver set with setResolver.

Fix: Import the helper from kubb/kit, and replace ctx.driver.getResolver(name) with ctx.getResolver(name) in a template, or with getResolver(name) from kubb/kit in any other hook, such as a visit hook. If a plugin triggers it, run pnpm update "@kubb/*" so every @kubb package is on one version.

KUBB_NO_CONTEXT

A kubb/kit composable such as useKubb() ran outside a plugin hook: setup, kubb:plugin:setup, a hook in the plugin's hooks map or a visit hook. addTemplate(), setResolver(), addMacro() and setMacros() also report it for a plugin defined with defineExtension from @kubb/core. setOptions(), useOptions() and injectFile() report it in any hook other than setup and kubb:plugin:setup.

Fix: Call it inside a plugin hook, or in code the hook awaits. Define the plugin with defineExtension from kubb/kit.

KUBB_PARSER_FAILED

A parser crashed while printing a generated file.

Fix: Check the parser options, then report the crash.

KUBB_PATH_TRAVERSAL

A resolved path escapes output.path, so Kubb refuses to write it.

Fix: Keep output.path, group.name, and resolver file.path results inside the output folder. Strip .. and separators from spec names.

KUBB_PLUGIN_FAILED

A plugin threw, or reported an error through ctx.error.

Fix: Check the plugin options and the node at at:, then report the crash.

KUBB_PLUGIN_NOT_FOUND

A plugin requires another that is not in the config. getResolver also throws it for a name that is neither a plugin in the config nor provided.

Fix: Add it to plugins in any order, or remove the plugin that needs it. For getResolver, fix the name. Do not add @kubb/plugin-oas: in v5 the adapter reads OpenAPI.

KUBB_POST_GENERATE_FAILED

An output.postGenerate command exited non-zero. Kubb still writes the files.

Fix: Run the command from the project root to see the error.

KUBB_REF_NOT_FOUND

A $ref points at a missing definition, or a file or URL Kubb cannot read.

Fix: Add the definition or file, or fix the $ref, then run kubb validate.

KUBB_ACCESS_REFUSED

The security rules of the run refuse a local file or a host. Most often a $ref points at it, but a URL or git input and the requests the CLI makes itself report it too. A secret file such as .env or a key is always refused. A file outside the project or a host that is not public is refused unless security allows it.

Fix: Move the file inside the project, inline the schema, or serve it from a public URL. When the message names a host, add it to net.allow in security.

KUBB_REGISTRY_FAILED

The extension registry returned no usable list of extensions.

Fix: Point KUBB_REGISTRY at a Kubb registry, or unset it.

KUBB_RENDER_FAILED

A JSX template returned something the renderer cannot use: text outside <Code> or <Raw>, a Promise from an async component, or a React element.

Fix: Keep components synchronous, set jsxImportSource to @kubb/renderer-jsx, and wrap text in <Code> or <Raw>.

KUBB_SNAPSHOT_FAILED

kubb studio snapshot could not package the output: it is over the size limit, two files share a path, a path is too long, or the dist build failed.

Fix: Follow the fix in the message, such as generating fewer files with include or exclude.

KUBB_STUDIO_COMMAND_REFUSED

The agent refused a command from Kubb Studio: a permission is missing, another command is running, or the request is invalid.

Fix: Grant the permission with kubb studio permissions, or wait for the running command.

KUBB_STUDIO_INCOMPATIBLE

Kubb Studio needs a newer agent than this Kubb version.

Fix: Upgrade kubb in the project, or pull the latest Kubb agent image.

KUBB_STUDIO_NOT_PAIRED

This machine has no agent token for the Studio URL and cannot pair here, as in CI.

Fix: Run kubb studio login on a machine with a browser. In CI, use kubb studio snapshot or KUBB_STUDIO_PAIRING_CODE.

KUBB_STUDIO_PROTOCOL

Kubb Studio answered a pairing or token request without the fields the agent needs.

Fix: Try again later, and update @kubb/cli if it keeps failing.

KUBB_STUDIO_REFUSED

Kubb Studio refused a pairing code or an agent token. A code works once, for 5 minutes. A token stops working once it expires or is revoked.

Fix: For an agent an MCP client paired, get a new code from the client's kubb_studio_connect tool. For any other agent, pair again with kubb studio login.

KUBB_STUDIO_WORKER_FAILED

The kubb studio start worker could not start, stop, or be verified, or it already runs for this project.

Fix: Read worker.log, whose path kubb studio status prints. Run kubb studio stop before a foreground kubb studio, or set KUBB_STUDIO_CONTROL_PORT when another program holds the port.

KUBB_UNKNOWN

An error without a Kubb code, such as one a plugin or adapter throws as a plain Error.

Fix: Read the message and the --verbose stack. Check the options of the plugin or adapter that threw it, or report it with the Environment: block.

Warnings

KUBB_ALIAS_CYCLE

Schemas that only $ref each other form a loop, so Kubb types them as unknown.

Fix: Give one schema a real definition, or remove the $ref that closes the loop.

KUBB_DUPLICATE_DISCRIMINATOR

oneOf or anyOf members share a discriminator value, so the discriminator cannot pick a member.

Fix: Give each member its own value, or drop the discriminator to match by shape.

KUBB_DUPLICATE_OPERATION_ID

Two operations share an operationId, so Kubb adds a _2, _3, … suffix to each later one. A generated id can collide too: /a-b and /a/b both get get_a-b. Ids that give the same generated name, such as get-pets and getPets, also count as the same. A suffix never takes an id that another operation declares.

Fix: Give each operation its own operationId.

KUBB_INVALID_SPEC

The spec fails OpenAPI schema validation, so the output can be incomplete or wrong.

Fix: Run kubb validate to list every problem, or set validate: false on the adapter to skip the check.

KUBB_OUTPUT_PASSES_SKIPPED

output.format, output.lint, or output.postGenerate is set, but the storage is not named fs, so Kubb cannot tell that the files are on disk. It skips those passes and the output manifest.

Fix: Run the tools yourself after the build, or remove the options. A custom storage that writes output.path to disk can use the name fs.

KUBB_OUTSIDE_OUTPUT

A plugin wrote a file outside output.path and shared.path. Kubb still writes it, but output.clean never removes it.

Fix: Check the plugin's output.path and its group.name function, so every generated path stays inside output.path.

KUBB_PLUGIN_WARNING

A plugin reported a non-fatal problem through ctx.warn.

Fix: Read the message and adjust the input or the plugin options.

KUBB_SHARED_FILE_MISMATCH

Configs that use the same shared.path generated different content for the same shared file, so the last config to write it wins.

Fix: Give the configs that use the same shared.path the same plugin options and banner.

KUBB_UNSUPPORTED_FORMAT

Kubb has no type for a schema's format, so it uses the base type.

Fix: Use a supported format, drop it, or handle it in a custom parser or plugin. When a plugin already handles the format, add the code to diagnostics.ignore.

Info

KUBB_DEPRECATED

The spec uses a schema or operation marked deprecated. Generation is unchanged.

Fix: Move off the deprecated definition when you can.

KUBB_PERFORMANCE

One plugin's generation time, shown with --verbose and as timings in Machine-readable output.

Fix: None needed.

KUBB_PLUGIN_INFO

A plugin reported a message through ctx.info, shown in the summary and JSON report.

Fix: None needed.

KUBB_UPDATE_AVAILABLE

npm has a newer Kubb than the one running. See Update check.

Fix: Update Kubb and your plugins.

Machine-readable output

kubb generate --reporter json prints a JSON array to stdout, one report per config, even for a single config.

Report
[
  {
    "name": "",
    "status": "failed",
    "plugins": { "passed": 2, "failed": ["plugin-zod"], "total": 3 },
    "counts": { "errors": 1, "warnings": 0, "infos": 0 },
    "filesCreated": 0,
    "filesUnchanged": 0,
    "filesFromLockfile": 0,
    "dryRun": false,
    "durationMs": 312,
    "output": "/project/src/gen",
    "timings": [{ "plugin": "plugin-ts", "durationMs": 84 }],
    "diagnostics": [
      {
        "code": "KUBB_REF_NOT_FOUND",
        "severity": "error",
        "message": "Could not find a definition for #/components/schemas/Pet.",
        "title": "Reference not found",
        "cause": "A `$ref` could not be resolved in the source document.",
        "location": { "kind": "schema", "pointer": "#/components/schemas/Pet" },
        "help": "Add the schema under components.schemas, or fix the $ref. Run `kubb validate` to check the spec.",
        "plugin": "plugin-zod",
        "docsUrl": "https://kubb.dev/docs/5.x/reference/diagnostics#kubb-ref-not-found"
      }
    ]
  }
]
FieldHolds
nameThe config name, or ""
countsDiagnostics by severity, without timings
timingsPer-plugin durations, slowest first
fileChangesFile and line changes, when collected
check.changedWith --check: true when the output on disk is out of date
check.filesWith --check: each out-of-date file as { path, status, linesAdded, linesRemoved }. path is relative to root, and status is added, modified, or deleted.
diagnostics[].title, .causeThe code's catalog entry
diagnostics[].helpIts own fix, or the catalog fix
diagnostics[].plugin, .issuesThe reporting plugin, and a crashed extension's issue tracker
diagnostics[].causes, .stackWrapped error messages, and a crash stack
diagnostics[].docsUrlThis page's entry. KUBB_UNKNOWN has none.

Any error still exits with code 1, or with code 2 under --check. See --reporter for other reporters.

Less common cases

Update check

When a run prints KUBB_UPDATE_AVAILABLE without a network request, it reuses an earlier answer.

  • kubb generate asks npm at most once every 24 hours and keeps the answer in KUBB_HOME (default ~/.kubb), so the notice also shows on runs that make no request.
  • CI skips the check, detected from variables such as CI or GITHUB_ACTIONS.

Diagnostic details

Each row adds what a code's entry leaves out.

CodeDetail
KUBB_ADAPTER_FAILEDErrors the adapter reports on purpose, such as KUBB_REF_NOT_FOUND, keep their own code.
KUBB_ADAPTER_REQUIREDdefineConfig adds the OpenAPI adapter when adapter is left out, so this happens only with a custom adapter or with createKubb from @kubb/core.
KUBB_BARREL_DUPLICATE_EXPORTThe barrel keeps the first export and drops the rest, so the code still parses, but the run fails. A type and a value may share a name.
KUBB_DUPLICATE_DISCRIMINATORZod's z.discriminatedUnion throws on the first parse of such a union.
KUBB_FORMAT_FAILEDCheck the formatter's install and config.
KUBB_GIT_INPUT_FAILEDgit is missing, the repository or ref does not exist, or the credentials were refused. For a private repository, set up a credential helper or SSH key.
KUBB_INCOMPATIBLE_EXTENSIONKubb checks at run time and in kubb add.
KUBB_INLINE_FAILEDThe imported name has no inline definition, refers to itself, or has no parser that supports inlining. One diagnostic lists every case.
KUBB_INPUT_NOT_FOUNDA URL reports KUBB_INPUT_REQUEST_FAILED or KUBB_INPUT_UNREACHABLE instead.
KUBB_INPUT_REQUEST_FAILEDA 404 means a wrong path, and a 5xx a failing server. The extension commands also report it for an invalid registry index.
KUBB_INPUT_UNREACHABLEThe cause is a refused connection, an unknown host, an expired certificate, or a timeout. The message names which one. For a local server, check the port.
KUBB_INTERNAL_ERRORThe bug is in Kubb, not in your config or spec. --reporter json also shows the stack.
KUBB_INVALID_DOCUMENTThe check runs even with validation off. A passed input must be the spec itself, not an HTML page or a wrapper object.
KUBB_INVALID_PLUGIN_OPTIONSSee Invalid plugin options.
KUBB_INVALID_SPECkubb validate lists every problem as an error and exits with code 1. @kubb/adapter-oas checks while validate is true, the default.
KUBB_NO_CONTEXTThe composable has no plugin to apply to. The message names the composable.
KUBB_PATH_TRAVERSALThe refusal stops a crafted spec or a wrong group.name from placing files elsewhere on disk.
KUBB_PERFORMANCEKubb never prints it as a problem. The time leaves out config loading, format, lint, and post-generate.
KUBB_PLUGIN_FAILEDThe diagnostic names the plugin and keeps the thrown error as its cause. Plugin authors can raise a stable code with Diagnostics.Error or Diagnostics.report.
KUBB_PLUGIN_NOT_FOUNDkubb init --plugins also reports it for an id the registry does not list.
KUBB_PLUGIN_WARNING, KUBB_PLUGIN_INFOPlugin authors can add a stable code and a location with Diagnostics.report.
KUBB_REF_NOT_FOUNDInside an x- vendor extension it is only a warning. Kubb refuses some local $ref files, such as any from a URL input. See External $ref files for the rules on Kubb Studio agents.
KUBB_UNKNOWNThe terminal shows no docs link for it. --reporter file writes a log with the stack in .kubb/.
KUBB_UNSUPPORTED_FORMATKubb reports each format once, with a count, at the first schema that uses it.

Invalid plugin options

When a run stops with KUBB_INVALID_PLUGIN_OPTIONS, the plugins array or a plugin's options cannot work as given. The message names the case:

  • group with file output: output.mode: 'file', or an output.path with an extension.
  • sdk.mode: 'tag' with file output on @kubb/plugin-fetch, @kubb/plugin-axios, or @kubb/plugin-client.
  • An option value the plugin does not accept.
  • A plugins entry that is not a plugin, such as pluginTs instead of pluginTs().
  • The same plugin twice, or a cycle in plugin dependencies.
  • An extension without meta.name or name.
  • A @kubb/plugin-faker dateParser that cannot format the adapter's dateType: 'date' values.

Change what the message names. A single file has nothing to group or split, so remove group, use sdk.mode: 'flat', or write to a directory.