hcengineering/platform · error

No default content adapter

Error message

No default content adapter

What it means

createContentAdapter builds a map of content adapters from configuration and selects the one whose contentType matches the configured default. If no registered adapter matches the defaultContentAdapter key, defaultAdapter stays undefined and this error is thrown instead of returning a ContentAdapter.

Source

Thrown at foundations/server/packages/core/src/content.ts:49

export async function createContentAdapter (
  contentAdapters: Record<string, ContentTextAdapterConfiguration>,
  defaultContentAdapter: string
): Promise<ContentTextAdapter> {
  const adapters = new Map<string, ContentTextAdapter>()
  let defaultAdapter: ContentTextAdapter | undefined

  for (const key in contentAdapters) {
    const adapterConf = contentAdapters[key]
    const adapter = await adapterConf.factory(adapterConf.url)

    adapters.set(adapterConf.contentType, adapter)
    if (key === defaultContentAdapter) {
      defaultAdapter = adapter
    }
  }
  if (defaultAdapter === undefined) {
    throw new Error('No default content adapter')
  }
  return new ContentAdapter(adapters, defaultAdapter)
}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Check the config passed to startIndexer: ensure defaultContentAdapter exactly matches one adapter's contentType
  2. Add or re-register an adapter for the configured default contentType
  3. Fix the typo/case mismatch between the default name and adapter contentType keys

Example fix

// before
adapters: [{ contentType: 'text/markdown' }], defaultContentAdapter: 'text/md'
// after
adapters: [{ contentType: 'text/markdown' }], defaultContentAdapter: 'text/markdown'
Defensive patterns

Strategy: validation

Validate before calling

const conf = getConf()
const hasDefault = conf.adapters.some(a => a.contentType === conf.defaultContentAdapter)
if (!hasDefault) throw new Error(`defaultContentAdapter '${conf.defaultContentAdapter}' has no matching adapter`)

Type guard

function hasDefaultAdapter(conf: { adapters: { contentType: string }[]; defaultContentAdapter: string }): boolean {
  return conf.adapters.some(a => a.contentType === conf.defaultContentAdapter)
}

Try / catch

try {
  const adapter = createContentAdapter(...)
} catch (err) {
  if (err instanceof Error && err.message === 'No default content adapter') {
    // fix config and retry / surface config error
  } else throw err
}

Prevention

When it happens

Trigger: Config lists adapters whose contentType values never equal the configured defaultContentAdapter key; or defaultContentAdapter names a contentType that has no adapter registered (typo, adapter omitted from config array).

Common situations: Typo in the default adapter name in workspace/server config; deploying with a custom content pipeline config where the default adapter section was removed; renaming a contentType in code without updating config.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/92bcd839cda3fba1. Report an issue: GitHub.