deepseek-ai/deepseek-harness · error · Error

permission settings has no defaultPreset value

Error message

permission settings has no defaultPreset value

What it means

permissionDefaultOf() reads the permission settings namespace view and requires a string defaultPreset inside view.value. A missing, null, or non-string value — view not yet loaded, an empty namespace, or a host writing a different value shape — throws 'permission settings has no defaultPreset value' before the schema is even consulted.

Source

Thrown at packages/client/ui-permission-presets/src/client/settings-store.ts:58

interface ConstChoice {
  type: string
  value?: unknown
  meta?: { description?: unknown }
}

/**
 * Read the dynamic preset enum encoded by the host's `defaultPreset` schema.
 * @param view - permission namespace descriptor.
 * @param schema - settings schema operations.
 * @returns current value and selectable options.
 */
export function permissionDefaultOf(view: SettingsNamespaceView, schema: SettingsSchemaService): {
  currentValue: string
  options: PermissionDefaultOption[]
} {
  const value = (view.value as { defaultPreset?: unknown } | null)?.defaultPreset
  if (typeof value !== 'string') throw new Error('permission settings has no defaultPreset value')
  const node = schema.nodeAtPath(schema.rehydrate(view.schema), ['defaultPreset'])
  if (node === undefined) throw new Error('permission settings schema has no defaultPreset field')
  const rawChoices = node.type === 'union'
    ? (node.list as SchemaNode[] | undefined) ?? []
    : [node]
  const options = rawChoices.flatMap((candidate) => {
    const choice = candidate as unknown as ConstChoice
    if (choice.type !== 'const' || typeof choice.value !== 'string') return []
    const described = choice.meta?.description
    return [{
      id: choice.value,
      label: typeof described === 'string' && described.length > 0
        ? displayPermissionPreset(choice.value, described)
        : displayPermissionPreset(choice.value, choice.value),
    }]
  })
  if (options.length === 0 || !options.some(option => option.id === value)) {
    throw new Error('permission settings schema does not advertise its current preset')

View on GitHub (pinned to b150a551b8)

Solutions

  1. Wait for the settings namespace view to be loaded and populated before resolving the default
  2. Verify the host actually writes defaultPreset as a string in that namespace
  3. Guard the call site with a readiness and typeof check on view.value

Example fix

// before
const { currentValue, options } = permissionDefaultOf(view, schema)
// after
if (typeof (view.value as { defaultPreset?: unknown } | null)?.defaultPreset !== 'string') {
  renderLoading()
  return
}
const { currentValue, options } = permissionDefaultOf(view, schema)
Defensive patterns

Strategy: validation

Validate before calling

const value = (view.value as { defaultPreset?: unknown } | null)?.defaultPreset
if (typeof value !== 'string') {
  renderLoading()
  return
}
return permissionDefaultOf(view, schema)

Type guard

function hasStringDefaultPreset(view: SettingsNamespaceView): boolean {
  return typeof (view.value as { defaultPreset?: unknown } | null)?.defaultPreset === 'string'
}

Prevention

When it happens

Trigger: Calling permissionDefaultOf on a SettingsNamespaceView whose value is null (settings not loaded yet), lacks the defaultPreset key, or carries it as a non-string; typical during early mount before settings arrive, or after a host config format change.

Common situations: Rendering the permission defaults UI before the settings view settles; host/client settings drift; a namespace rename yielding an empty view.

Related errors


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/f5262db3007c5698. Report an issue: GitHub.