From: Kefu Chai Date: Fri, 10 Apr 2026 04:39:36 +0000 (+0800) Subject: mgr/dashboard: return 400 for all tracker API errors in feedback X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f31b22f2e74189f75882d29ce50a43a0e624e57e;p=ceph.git mgr/dashboard: return 400 for all tracker API errors in feedback 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 --- diff --git a/src/pybind/mgr/dashboard/controllers/feedback.py b/src/pybind/mgr/dashboard/controllers/feedback.py index c75ffa94a89f..c1b51dca3f85 100644 --- a/src/pybind/mgr/dashboard/controllers/feedback.py +++ b/src/pybind/mgr/dashboard/controllers/feedback.py @@ -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