medusajs/medusa · warning

'link' is missing.

Error message

'link' is missing.

What it means

The admin-vite-plugin generates link registrations for custom field configs. Each config passed to defineCustomFieldConfig must include a `link` property that points to the link object exported from the generated links file. When the plugin parses the config object literal and finds no `link` key, it logs this warning and skips generating the link for that custom field, so the custom field will not be linked to its module.

Source

Thrown at packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-links.ts:161

}

function getLink(
  path: NodePath<ExportDefaultDeclaration>,
  index: number,
  file: string
): string | null {
  const configArgument = getConfigArgument(path)

  if (!configArgument) {
    return null
  }

  const linkProperty = configArgument.properties.find(
    (p) => isObjectProperty(p) && isIdentifier(p.key, { name: "link" })
  ) as ObjectProperty | undefined

  if (!linkProperty) {
    logger.warn(`'link' is missing.`, { file })
    return null
  }

  const import_ = generateCustomFieldConfigName(index)

  return `${import_}.link`
}

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Open the custom field's config.ts and add a `link` property referencing the default export of ./links (e.g. `link: productCustomFieldLink`)
  2. Ensure links.ts exists in the same folder and exports a link created with defineLink(<Model>, <ModuleModel>)
  3. Restart the dev server so the vite plugin re-scans the custom field directories

Example fix

// before
export default defineCustomFieldConfig({
  model: productCustomField,
})

// after
import productCustomFieldLink from "./links"

export default defineCustomFieldConfig({
  model: productCustomField,
  link: productCustomFieldLink,
})
Defensive patterns

Strategy: validation

Validate before calling

// before building, assert the config has a link key
const config = await import("./custom-fields/product/config.ts").then(m => m.default)
if (!config || !("link" in config) || !config.link) {
  throw new Error("Custom field config is missing 'link'")
}

Type guard

const hasLink = (c: unknown): c is { link: unknown } =>
  typeof c === "object" && c !== null && "link" in c && (c as any).link != null

Prevention

When it happens

Trigger: Exporting a config object from src/admin/custom-fields/<name>/config.ts via defineCustomFieldConfig (or a plain default export object) that omits the `link` key.

Common situations: Developer creates a custom field folder with only a config.ts and forgets the accompanying links.ts; or renames/removes the link import and its usage while keeping the rest of the config.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/084bd000d7e6082a. Report an issue: GitHub.