-
Notifications
You must be signed in to change notification settings - Fork 6
TEL-6714: [b2bua] Resolve ERR log mod_http_cache.c:1294 HTTP 403 to WARNING #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: telnyx/telephony/deploy-development
Are you sure you want to change the base?
Conversation
ai-swe-codereviewer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
This PR attempts to reduce ERROR log noise by downgrading various log messages to WARNING level. However, the changes go far beyond the stated scope (HTTP 403 errors on line 1294) and include many unrelated error conditions.
Critical Issues:
-
Scope creep: The PR description claims to only change line 1294 for HTTP 403 errors, but actually changes 15 different log statements across the entire file.
-
Indiscriminate downgrading: Many of the changed log statements represent genuine ERROR conditions that should not be downgraded:
- System call failures (fopen, fstat, write, open)
- Critical initialization failures (curl init, config file parsing)
- Configuration validation errors that cause module termination (SWITCH_STATUS_TERM)
- File operation failures during cache operations
-
Loss of critical diagnostics: Downgrading these errors will make it harder to diagnose real system issues like:
- Disk space problems
- Permission issues
- Configuration errors
- Network/curl initialization failures
Recommendation: Only change line 1294 (and possibly line 1264 for retry attempts) as originally intended. The other log statements represent legitimate ERROR conditions that should remain at ERROR level to maintain proper system diagnostics and troubleshooting capabilities.
| file_to_put = fopen(filename, "rb"); | ||
| if (!file_to_put) { | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fopen() error: %s\n", strerror(errno)); | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "fopen() error: %s\n", strerror(errno)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading fopen() failure to WARNING is problematic. If the file cannot be opened, the function returns SWITCH_STATUS_FALSE, indicating a real error condition that should be logged as ERROR.
|
|
||
| if (fstat(fileno(file_to_put), &file_info) == -1) { | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fstat() error: %s\n", strerror(errno)); | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "fstat() error: %s\n", strerror(errno)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading fstat() failure to WARNING is problematic. This is a system call failure that causes the function to return SWITCH_STATUS_FALSE, indicating a real error that should remain at ERROR level.
| curl_handle = switch_curl_easy_init(); | ||
| if (!curl_handle) { | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "switch_curl_easy_init() failure\n"); | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "switch_curl_easy_init() failure\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading curl initialization failure to WARNING is problematic. If curl cannot be initialized, the function returns SWITCH_STATUS_FALSE. This is a critical failure that should remain at ERROR level.
| size_t result = 0; | ||
| if (bytes_written == -1) { | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "write(): %s\n", strerror(errno)); | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "write(): %s\n", strerror(errno)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading write() system call failure to WARNING is problematic. A write failure during HTTP response handling is a serious error that could lead to data corruption or incomplete downloads.
| } else { | ||
| if (bytes_written != realsize) { | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "write(): short write!\n"); | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "write(): short write!\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading short write detection to WARNING is problematic. A short write indicates potential data loss or corruption and should remain at ERROR level.
| } | ||
| if (zstr(cache->location)) { | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "location must not be empty\n"); | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "location must not be empty\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading empty location configuration error to WARNING is problematic. This validation failure causes SWITCH_STATUS_TERM to be returned, preventing module initialization.
| } | ||
| if (default_max_age_sec <= 0) { | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "default-max-age must be > 0\n"); | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "default-max-age must be > 0\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading invalid default-max-age configuration to WARNING is problematic. This validation failure causes SWITCH_STATUS_TERM to be returned, preventing module initialization.
| } | ||
| if (cache->prefetch_queue_size <= 0) { | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "prefetch-queue-size must be > 0\n"); | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "prefetch-queue-size must be > 0\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading invalid prefetch-queue-size configuration to WARNING is problematic. This validation failure causes SWITCH_STATUS_TERM to be returned, preventing module initialization.
| } | ||
| if (cache->prefetch_thread_count <= 0) { | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "prefetch-thread-count must be > 0\n"); | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "prefetch-thread-count must be > 0\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading invalid prefetch-thread-count configuration to WARNING is problematic. This validation failure causes SWITCH_STATUS_TERM to be returned, preventing module initialization.
| handle->samplerate, | ||
| file_flags, NULL)) != SWITCH_STATUS_SUCCESS) { | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open HTTP cache file: %s, %s\n", context->local_path, path); | ||
| switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to open HTTP cache file: %s, %s\n", context->local_path, path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrading file open failure to WARNING is problematic. This error occurs when the cached file cannot be opened for playback, which is a real error condition that should remain at ERROR level.
6cc2de6 to
491c008
Compare
Summary
This pull request addresses TEL-6714 by changing the log level of HTTP 403 curl errors in mod_http_cache.c from ERROR to WARNING.
Changes
src/mod/applications/mod_http_cache/mod_http_cache.cSWITCH_LOG_ERROR→SWITCH_LOG_WARNINGContext
The error log entry:
This error occurs at 85.80% frequency and was identified as part of the broader effort to clean up ERR and CRIT logs on b2bua (parent epic TEL-6680). The team determined that HTTP 403 errors, while potentially indicating issues, should be logged at WARNING level rather than ERROR level to reduce log noise.
Rationale
Related Tickets
Testing