{"record":{"id":"f5262db3007c5698","repo":"deepseek-ai/deepseek-harness","slug":"permission-settings-has-no-defaultpreset-value","errorCode":null,"errorMessage":"permission settings has no defaultPreset value","messagePattern":"permission settings has no defaultPreset value","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/ui-permission-presets/src/client/settings-store.ts","lineNumber":58,"sourceCode":"\ninterface ConstChoice {\n  type: string\n  value?: unknown\n  meta?: { description?: unknown }\n}\n\n/**\n * Read the dynamic preset enum encoded by the host's `defaultPreset` schema.\n * @param view - permission namespace descriptor.\n * @param schema - settings schema operations.\n * @returns current value and selectable options.\n */\nexport function permissionDefaultOf(view: SettingsNamespaceView, schema: SettingsSchemaService): {\n  currentValue: string\n  options: PermissionDefaultOption[]\n} {\n  const value = (view.value as { defaultPreset?: unknown } | null)?.defaultPreset\n  if (typeof value !== 'string') throw new Error('permission settings has no defaultPreset value')\n  const node = schema.nodeAtPath(schema.rehydrate(view.schema), ['defaultPreset'])\n  if (node === undefined) throw new Error('permission settings schema has no defaultPreset field')\n  const rawChoices = node.type === 'union'\n    ? (node.list as SchemaNode[] | undefined) ?? []\n    : [node]\n  const options = rawChoices.flatMap((candidate) => {\n    const choice = candidate as unknown as ConstChoice\n    if (choice.type !== 'const' || typeof choice.value !== 'string') return []\n    const described = choice.meta?.description\n    return [{\n      id: choice.value,\n      label: typeof described === 'string' && described.length > 0\n        ? displayPermissionPreset(choice.value, described)\n        : displayPermissionPreset(choice.value, choice.value),\n    }]\n  })\n  if (options.length === 0 || !options.some(option => option.id === value)) {\n    throw new Error('permission settings schema does not advertise its current preset')","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/client/ui-permission-presets/src/client/settings-store.ts#L40-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"Rendering the permission defaults UI before the settings view settles; host/client settings drift; a namespace rename yielding an empty view.","solutions":["Wait for the settings namespace view to be loaded and populated before resolving the default","Verify the host actually writes defaultPreset as a string in that namespace","Guard the call site with a readiness and typeof check on view.value"],"exampleFix":"// before\nconst { currentValue, options } = permissionDefaultOf(view, schema)\n// after\nif (typeof (view.value as { defaultPreset?: unknown } | null)?.defaultPreset !== 'string') {\n  renderLoading()\n  return\n}\nconst { currentValue, options } = permissionDefaultOf(view, schema)","handlingStrategy":"validation","validationCode":"const value = (view.value as { defaultPreset?: unknown } | null)?.defaultPreset\nif (typeof value !== 'string') {\n  renderLoading()\n  return\n}\nreturn permissionDefaultOf(view, schema)","typeGuard":"function hasStringDefaultPreset(view: SettingsNamespaceView): boolean {\n  return typeof (view.value as { defaultPreset?: unknown } | null)?.defaultPreset === 'string'\n}","tryCatchPattern":null,"preventionTips":["Wait for the settings namespace view to settle before resolving defaults","Type-check view.value fields at the boundary — the view is untyped JSON"],"tags":["settings","config","plugin-composition","validation"],"backgroundTag":"missing-config-value","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}