Sitelet https://github.com/keephq/keep/issues/6715
Skip to content

openai and deepseek providers crash on an empty choices list #6715

Description

@chiruu12

Both the OpenAI and DeepSeek providers read response.choices[0].message.content without checking that choices is non-empty:

  • keep/providers/openai_provider/openai_provider.py:69
  • keep/providers/deepseek_provider/deepseek_provider.py:83

An OpenAI-compatible backend can return HTTP 200 with an empty choices list, for example when a content filter blocks the completion. choices[0] then raises IndexError and the workflow step fails instead of degrading.

This is the same failure fixed for litellm/vllm in #6705 and for grok in #6710; these two providers were not covered.

Reproduction

Call _query with a client whose response has choices == []:

IndexError: list index out of range

Expected

Return an empty string, the way grok/litellm/vllm now do, so an empty completion does not crash the step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingProviderProviders related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions