Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#55581] user generic error message for missing users

Tobias Dillmannf60f74428a24
diff --git a/app/components/users/hover_card_component.html.erb b/app/components/users/hover_card_component.html.erb
index 1bc4de56a89..7af47f81965 100644
--- a/app/components/users/hover_card_component.html.erb
+++ b/app/components/users/hover_card_component.html.erb
@@ -79,7 +79,8 @@ See COPYRIGHT and LICENSE files for more details.
else
render Primer::Beta::Blankslate.new(border: false, narrow: true) do |component|
component.with_visual_icon(icon: "x-circle")
- component.with_heading(tag: :h3).with_content(I18n.t("api_v3.errors.not_found.user"))
+ # Show a generic error message to avoid leaking information
+ component.with_heading(tag: :h3).with_content(I18n.t("http.response.unexpected"))
end
end
%>
diff --git a/app/components/users/hover_card_component.rb b/app/components/users/hover_card_component.rb
index afd040da99b..6afd44af19b 100644
--- a/app/components/users/hover_card_component.rb
+++ b/app/components/users/hover_card_component.rb
@@ -35,7 +35,7 @@ class Users::HoverCardComponent < ApplicationComponent
super
@id = id
- @user = User.find(@id)
+ @user = User.find_by(id: @id)
end
def show_email?
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3f0d35b3e96..740667da160 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -4136,7 +4136,6 @@ en:
code_500_missing_enterprise_token: "The request can not be handled due to invalid or missing Enterprise token."
not_found:
work_package: "The work package you are looking for cannot be found or has been deleted."
- user: "The user you are looking for cannot be found or has been deleted."
expected:
date: "YYYY-MM-DD (ISO 8601 date only)"
datetime: "YYYY-MM-DDThh:mm:ss[.lll][+hh:mm] (any compatible ISO 8601 datetime)"
diff --git a/spec/components/users/hover_card_component_spec.rb b/spec/components/users/hover_card_component_spec.rb
index 450fbbcb963..789823d3d86 100644
--- a/spec/components/users/hover_card_component_spec.rb
+++ b/spec/components/users/hover_card_component_spec.rb
@@ -53,6 +53,14 @@ RSpec.describe Users::HoverCardComponent, type: :component do
page.find_test_selector("user-hover-card-name", text: user.name)
end
+ context "when the user does not exist" do
+ let(:user) { instance_double(User, id: 9000) }
+
+ it "renders a generic error message" do
+ expect(page).to have_text(I18n.t("http.response.unexpected"))
+ end
+ end
+
context "when displaying email addresses" do
it "hides the email address of a user" do
expect(page).not_to have_test_selector("user-hover-card-email")