Fixed handling of the error messages in GitLab chat
What does this MR do and why?
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
- Follow the instructions to enable the AI features in your local GDK
- Follow the instructions on setting up the GitLab chat locally
- Enable the
:super_sidebar_nav
feature flag (Feature.enable(:anthropic_experimentation)
in your rails console - Enable the new super sidebar in your settings via the web interface:
- Apply the patch (a hack to provide some fixes to BE while the corresponding MRs are not merged):
BE patch
diff --git a/app/models/user.rb b/app/models/user.rb
index c5c0353e6f43..b5e48abbc0e4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -2334,6 +2334,10 @@ def consume_otp!
false
end
+ def resource_parent
+ self.namespace
+ end
+
private
def block_or_ban
diff --git a/ee/app/services/llm/chat_service.rb b/ee/app/services/llm/chat_service.rb
index 5fa7ae8a2bc1..5fe996ba0345 100644
--- a/ee/app/services/llm/chat_service.rb
+++ b/ee/app/services/llm/chat_service.rb
@@ -5,7 +5,7 @@ class ChatService < BaseService
private
def perform
- worker_perform(user, resource, :chat, options)
+ worker_perform(user, resource, :chat, options.merge(sync: true))
end
def valid?
diff --git a/ee/lib/gitlab/llm/chain/tools/issue_identifier/executor.rb b/ee/lib/gitlab/llm/chain/tools/issue_identifier/executor.rb
index 3aeefd970fc4..4466b68ed365 100644
--- a/ee/lib/gitlab/llm/chain/tools/issue_identifier/executor.rb
+++ b/ee/lib/gitlab/llm/chain/tools/issue_identifier/executor.rb
@@ -119,7 +119,7 @@ def perform
private
def authorize
- Utils::Authorizer.context_authorized?(context: context)
+ true#Utils::Authorizer.context_authorized?(context: context)
end
def already_identified?
@@ -149,7 +149,7 @@ def identify_issue(resource_identifier_type, resource_identifier)
extract_issue(resource_identifier)
end
- return issue if Utils::Authorizer.resource_authorized?(resource: issue, user: context.current_user)
+ return issue #if Utils::Authorizer.resource_authorized?(resource: issue, user: context.current_user)
end
def by_iid(resource_identifier)
diff --git a/ee/lib/gitlab/llm/chain/tools/tool.rb b/ee/lib/gitlab/llm/chain/tools/tool.rb
index 3716376bbe43..c28085e6439b 100644
--- a/ee/lib/gitlab/llm/chain/tools/tool.rb
+++ b/ee/lib/gitlab/llm/chain/tools/tool.rb
@@ -46,6 +46,8 @@ def projects_from_context
[context.container.project]
when Group
context.container.all_projects
+ else
+ [context.current_user.authorized_projects.first]
end
end
strong_memoize_attr :projects_from_context
diff --git a/ee/lib/gitlab/llm/chain/utils/authorizer.rb b/ee/lib/gitlab/llm/chain/utils/authorizer.rb
index 7b9b7ada2550..30ec8af5b0b7 100644
--- a/ee/lib/gitlab/llm/chain/utils/authorizer.rb
+++ b/ee/lib/gitlab/llm/chain/utils/authorizer.rb
@@ -25,7 +25,7 @@ def self.container_authorized?(container:)
def self.resource_authorized?(resource:, user:)
return unless resource
- container = resource&.resource_parent&.root_ancestor
+ container = resource&.try(:resource_parent)&.root_ancestor
return false if !container || !container_authorized?(container: container)
user.can?("read_#{resource.to_ability_name}", resource)
You should be able to ask questions like on the After screenshot with those being output into the Chat UI once the response is received
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #414884
Edited by Denys Mishunov