{"record":{"id":"b6ee9a71fa2946fa","repo":"usememos/memos","slug":"ai-provider-capability-unsupported","errorCode":null,"errorMessage":"AI provider capability unsupported","messagePattern":"AI provider capability unsupported","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/ai/errors.go","lineNumber":9,"sourceCode":"package ai\n\nimport \"github.com/pkg/errors\"\n\nvar (\n\t// ErrProviderNotFound indicates that a requested provider ID does not exist.\n\tErrProviderNotFound = errors.New(\"AI provider not found\")\n\t// ErrCapabilityUnsupported indicates that the provider does not support the requested capability.\n\tErrCapabilityUnsupported = errors.New(\"AI provider capability unsupported\")\n\t// ErrSTTNotSupported indicates that the provider does not have a dedicated\n\t// speech-to-text endpoint. Use the audiollm package for multimodal audio\n\t// understanding when this is returned.\n\tErrSTTNotSupported = errors.New(\"provider does not support speech-to-text capability\")\n\t// ErrAudioLLMNotSupported indicates that the provider does not have a\n\t// multimodal-audio LLM available in this codebase.\n\tErrAudioLLMNotSupported = errors.New(\"provider does not support multimodal audio capability\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/internal/ai/errors.go#L1-L18","documentation":"Sentinel error ai.ErrCapabilityUnsupported indicating the requested AI provider exists but does not support the capability being requested (as opposed to ErrProviderNotFound for a bad ID, or the STT/audio-LLM-specific sentinels). Compare with errors.Is rather than string matching.","triggerScenarios":"Calling the ai package's capability factory with a provider ID that exists but lacks the requested capability — e.g., asking a text-only provider for STT or multimodal audio, or a provider family whose driver implements one capability only. The dispatch layer returns this sentinel before constructing a client.","commonSituations":"Mixing provider types in AI settings (pointing STT at a chat-only provider); upgrading/downgrading where a capability was added or removed per provider; custom OpenAI-compatible endpoints that only proxy chat completions.","solutions":["Switch the AI settings to a provider that supports the capability you are invoking (for speech-to-text see the dedicated STT providers; for multimodal audio see the audiollm path).","Check errors.Is(err, ai.ErrCapabilityUnsupported) and route the user to a supported provider or a graceful 'unsupported' UI state.","Review the provider capability matrix in the ai package/internal config and align the requested capability with a listed provider."],"exampleFix":"// before\nres, err := svc.Transcribe(ctx, req) // opaque error\n\n// after\nres, err := svc.Transcribe(ctx, req)\nif err != nil {\n  if errors.Is(err, ai.ErrCapabilityUnsupported) {\n    return status.Errorf(codes.InvalidArgument, \"configured AI provider lacks this capability; pick another provider\")\n  }\n  return err\n}","handlingStrategy":"type-guard","validationCode":"// Go — check capability support before requesting it\ncaps, ok := ai.ProviderCapabilities(providerID)\nif !ok {\n  return ai.ErrProviderNotFound\n}\nif !caps.Has(ai.CapSTT) {\n  return status.Errorf(codes.InvalidArgument, \"provider %q cannot transcribe; select an STT-capable provider\", providerID)\n}","typeGuard":"// Go\nfunc isCapabilityUnsupported(err error) bool {\n  return errors.Is(err, ai.ErrCapabilityUnsupported)\n}","tryCatchPattern":"res, err := svc.Invoke(ctx, req)\nif err != nil {\n  switch {\n  case errors.Is(err, ai.ErrCapabilityUnsupported):\n    return status.Errorf(codes.InvalidArgument, \"AI provider lacks this capability\")\n  case errors.Is(err, ai.ErrProviderNotFound):\n    return status.Errorf(codes.NotFound, \"AI provider not found\")\n  }\n  return err\n}","preventionTips":["Compare with errors.Is against the package sentinels; never string-match.","Surface provider capability lists in the settings UI so users pick valid providers.","On provider upgrades, re-run capability-related tests for every configured provider."],"tags":["ai","capability","sentinel-error","go","configuration"],"backgroundTag":null,"analyzedSha":"14d757ce1fb31c78590f374bc042f8dbedbc20d7","analyzedAt":"2026-08-15T09:27:36.538Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}