empty response causes json parse warning
Summary
There is an edge case where a neighbor isn't found, an empty response is returned. This needs to be changed now that everything is moved over to GraphQL
Bug description
From @dmishunov
when testing the chat, I’ve encountered an interesting edge case. I have not had tanuki_bot_mvc table populated as described in gitlab-com/gl-infra/production#10588 (comment 1373586079) and tried using the chat. The response never came back to me (it came only after I populated the table), but instead of returning I don't know right away, the rails-background-jobs threw a WARN for grapql:tanukiBot with
"exception.class": "JSON::ParserError",
"exception.message": "unexpected colon (after ) at line 1, column 2 [parse.c:703] in '{:msg=\u003e\"I do not know.\", :sources=\u003e[]}",
which, I believe, refers to https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/gitlab/llm/tanuki_bot.rb#L152-155. Should that empty_response be something like
def empty_response {msg: _("I do not know."), sources: []}.to_json end
Possible fixes
- Need to find an example question to test with and see response back (or use an empty database as described)
- Update specs to emulate this path
- convert response to json, just not sure where the best place to do this is. I would start at ee/lib/gitlab/llm/open_ai/response_modifiers/tanuki_bot.rb