]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: return 400 for all tracker API errors in feedback
authorKefu Chai <k.chai@proxmox.com>
Fri, 10 Apr 2026 04:39:36 +0000 (12:39 +0800)
committerKefu Chai <k.chai@proxmox.com>
Fri, 10 Apr 2026 04:54:35 +0000 (12:54 +0800)
The feedback create endpoint previously classified most tracker API
errors as 500 (Internal Server Error) and relied on fragile string
matching to detect the single "Invalid issue tracker API key" case
for a 400 response.

This caused intermittent test failures (and misleading errors for
users) whenever tracker.ceph.com returned something other than a
plain 401 — e.g., 5xx, forbidden, or a network error. Because the
error message would not match the magic string and the code would
fall through to a hardcoded 500.

Any failure from an upstream API is by definition not an internal
server error. Surface all RuntimeError from the feedback module as
a 400 DashboardException, letting the caller see the underlying
tracker error message.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/pybind/mgr/dashboard/controllers/feedback.py

index c75ffa94a89fda19c609377adeaf775ffeefa83c..c1b51dca3f85db266fb693476987b4414d8004e1 100644 (file)
@@ -38,14 +38,11 @@ class FeedbackController(RESTController):
             response = mgr.remote('feedback', 'validate_and_create_issue',
                                   project, tracker, subject, description, api_key)
         except RuntimeError as error:
-            if "Invalid issue tracker API key" in str(error):
-                raise DashboardException(msg='Error in creating tracker issue: Invalid API key',
-                                         component='feedback')
-            if "KeyError" in str(error):
-                raise DashboardException(msg=f'Error in creating tracker issue: {error}',
-                                         component='feedback')
-            raise DashboardException(msg=f'{error}',
-                                     http_status_code=500,
+            # Any failure from the tracker API (invalid key, network error,
+            # upstream 5xx, etc.) is a client/upstream error, not an internal
+            # server error. Surface it as 400 via DashboardException's default
+            # status code.
+            raise DashboardException(msg=f'Error in creating tracker issue: {error}',
                                      component='feedback')
 
         return response