fix(jira): report which admin config field is actually missing
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
POST /system/jira-test bundled 4 independent checks (enabled, url, admin_email, admin_api_token) behind has_admin_jira_configured() but always blamed "Admin Email and Admin API Token" regardless of which one failed. Found via live QA: URL/email/token were all correctly saved, but the "Enable Jira Integration" toggle was never switched on — the error message pointed at the wrong fields, making it look like the already-set credentials were missing.
This commit is contained in:
@@ -354,7 +354,7 @@ def test_jira_connection(
|
||||
"""
|
||||
from app.services.jira_service import (
|
||||
get_admin_jira_client, get_jira_url, has_admin_jira_configured,
|
||||
get_admin_jira_email,
|
||||
get_admin_jira_email, get_admin_jira_api_token, is_jira_enabled,
|
||||
)
|
||||
|
||||
jira_url = get_jira_url(db)
|
||||
@@ -362,12 +362,21 @@ def test_jira_connection(
|
||||
return {"status": "error", "message": "Jira URL is not configured.", "jira_url": ""}
|
||||
|
||||
if not has_admin_jira_configured(db):
|
||||
# has_admin_jira_configured() bundles 4 independent checks into one
|
||||
# bool — report exactly which one(s) are actually missing instead of
|
||||
# always blaming "Admin Email and Admin API Token" regardless of
|
||||
# which check failed (e.g. URL/email/token can all be set while the
|
||||
# "Enable Jira Integration" toggle itself is still off).
|
||||
missing = []
|
||||
if not is_jira_enabled(db):
|
||||
missing.append("Jira integration is not enabled (toggle 'Enable Jira Integration' above)")
|
||||
if not get_admin_jira_email(db):
|
||||
missing.append("Admin Email is not set")
|
||||
if not get_admin_jira_api_token(db):
|
||||
missing.append("Admin API Token is not set")
|
||||
return {
|
||||
"status": "error",
|
||||
"message": (
|
||||
"Admin Jira credentials not configured. "
|
||||
"Set the Admin Email and Admin API Token in the fields above."
|
||||
),
|
||||
"message": "Cannot connect: " + "; ".join(missing) + ".",
|
||||
"jira_url": jira_url,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user