From a9355852edede9662762847e0d168663083fc816 Mon Sep 17 00:00:00 2001 From: Deborah Kaplan Date: Thu, 18 Jul 2024 15:33:15 -0400 Subject: [PATCH] test: improve logging for periodic error (#35141) we have a periodic error that makes no sense when the certificate available date is none. This improves logging for the API call. Because the only thing being changed is a course certificate, there is no risk of PII being exposed in the new logging. --- openedx/core/djangoapps/programs/tasks.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/openedx/core/djangoapps/programs/tasks.py b/openedx/core/djangoapps/programs/tasks.py index 9338045cf8..42548fd494 100644 --- a/openedx/core/djangoapps/programs/tasks.py +++ b/openedx/core/djangoapps/programs/tasks.py @@ -235,15 +235,16 @@ def post_course_certificate_configuration(client, cert_config, certificate_avail """ credentials_api_base_url = get_credentials_api_base_url() credentials_api_url = urljoin(f"{credentials_api_base_url}/", "course_certificates/") + certificate_config = { + "course_id": cert_config["course_id"], + "certificate_type": cert_config["mode"], + "certificate_available_date": certificate_available_date, + "is_active": True, + } response = client.post( credentials_api_url, - json={ - "course_id": cert_config["course_id"], - "certificate_type": cert_config["mode"], - "certificate_available_date": certificate_available_date, - "is_active": True, - }, + json=certificate_config, ) # Sometimes helpful error context is swallowed when calling `raise_for_status()`. We try to print out any additional @@ -253,8 +254,8 @@ def post_course_certificate_configuration(client, cert_config, certificate_avail # 201 on a successful call. if response.status_code != 201: LOGGER.error( - "Error creating or updating a course certificate configuration in the Credentials IDA. Additional details: " - f"{response.text}" + "Error creating or updating a course certificate configuration in the Credentials IDA.\n" + f"config sent: {certificate_config}\nAdditional details: {response.text}" ) response.raise_for_status()