Skip to content

Commit

Permalink
test: improve logging for periodic error (#35141)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deborahgu authored Jul 18, 2024
1 parent 058870e commit a935585
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions openedx/core/djangoapps/programs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down

0 comments on commit a935585

Please sign in to comment.