fix: pass application/json for GenericAPILogger (#10772)

* fix: pass application/json for GenericAPILogger

* fix: test_generic_api_callback
This commit is contained in:
Ishaan Jaff 2025-05-12 14:15:33 -07:00 committed by GitHub
parent 51930c07c5
commit a4fb1da2d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -74,7 +74,9 @@ class GenericAPILogger(CustomBatchLogger):
headers: Optional[dict] = None
"""
# Process headers from different sources
headers_dict = {}
headers_dict = {
"Content-Type": "application/json",
}
# 1. First check for headers from env var
env_headers = os.getenv("GENERIC_LOGGER_HEADERS")

View file

@ -78,6 +78,9 @@ async def test_generic_api_callback():
print("##########\n")
print("logs were flushed to URL", actual_url, "with the following headers", mock_post.call_args[1]["headers"])
assert actual_url == test_endpoint, f"Expected URL {test_endpoint}, got {actual_url}"
# Validate headers
assert mock_post.call_args[1]["headers"]["Content-Type"] == "application/json", "Content-Type should be application/json"
# For the GenericAPILogger, it sends the payload directly as JSON in the data field
json_data = mock_post.call_args[1]["data"]