fix: remove hardcoded master_debug flag from api_calls.py (#28) #58

Merged
cal merged 1 commits from ai/paper-dynasty-discord-28 into next-release 2026-03-07 07:43:42 +00:00
Owner

Summary

Removes the hardcoded master_debug = True flag that was forcing all API request/response logging to INFO level regardless of the configured LOG_LEVEL.

Changes

  • Removed master_debug = True (line 20)
  • Replaced all 5 conditional logger.info(...) if master_debug else logger.debug(...) calls with unconditional logger.debug(...)
  • Fixed log_return_value() to use logger.debug instead of logger.info (was logging up to 300,000 chars per response at INFO level)
  • Removed dead commented-out code in log_return_value that referenced master_debug

Files Changed

  • api_calls.py

Impact

In production with LOG_LEVEL=INFO (default), API request/response details will no longer flood the logs. They will only appear when LOG_LEVEL=DEBUG is explicitly set.

Other observations

  • PLAYER_CACHE = {} (line 20 post-fix) is still an unused dead variable — tracked in issue #37.
## Summary Removes the hardcoded `master_debug = True` flag that was forcing all API request/response logging to INFO level regardless of the configured `LOG_LEVEL`. ## Changes - **Removed** `master_debug = True` (line 20) - **Replaced** all 5 conditional `logger.info(...) if master_debug else logger.debug(...)` calls with unconditional `logger.debug(...)` - **Fixed** `log_return_value()` to use `logger.debug` instead of `logger.info` (was logging up to 300,000 chars per response at INFO level) - **Removed** dead commented-out code in `log_return_value` that referenced `master_debug` ## Files Changed - `api_calls.py` ## Impact In production with `LOG_LEVEL=INFO` (default), API request/response details will no longer flood the logs. They will only appear when `LOG_LEVEL=DEBUG` is explicitly set. ## Other observations - `PLAYER_CACHE = {}` (line 20 post-fix) is still an unused dead variable — tracked in issue #37.
cal added 1 commit 2026-03-05 10:32:28 +00:00
fix: remove hardcoded master_debug flag from api_calls.py (#28)
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m11s
56fe8a6099
Remove master_debug = True and replace all conditional INFO/DEBUG log
calls with unconditional logger.debug(). Also switches log_return_value
to logger.debug and removes the associated dead commented-out code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cal added the
ai-reviewing
label 2026-03-05 10:45:32 +00:00
cal reviewed 2026-03-05 10:46:28 +00:00
cal left a comment
Author
Owner

AI Code Review

Files Reviewed

  • api_calls.py (modified)

Findings

Correctness

  • All 5 conditional logger.info(...) if master_debug else logger.debug(...) calls correctly replaced with unconditional logger.debug(...). Since master_debug was hardcoded True, these were always taking the INFO branch — the fix is accurate.
  • log_return_value() correctly updated to logger.debug — previously this could log up to 300,000 chars of API response data at INFO level in production.
  • The logger.warning("[ S N I P P E D ]") sentinel at the end of log_return_value is intentionally kept at WARNING level to signal truncation. This is appropriate.
  • Dead commented-out code (# if master_debug: block in log_return_value) cleanly removed.
  • PR description accurately describes all changes made.

Security

  • Minor improvement: API payloads and response bodies were previously logged at INFO level in production. Downgrading to DEBUG means sensitive payload data no longer appears in production logs by default.

Style & Conventions

  • No issues. Clean, minimal change consistent with existing patterns.

Suggestions

  • None. The fix is tightly scoped and complete.

Verdict: APPROVED

Straightforward, correct fix. Removes a hardcoded debug flag that was causing verbose API logging at INFO level in production. All 6 log-level changes (5 inline + log_return_value) are correct, dead code is cleaned up, and the behavioral change is exactly as described.

Note: Gitea does not allow self-approval. Verdict is APPROVED — no blocking issues found.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `api_calls.py` (modified) ### Findings #### Correctness - All 5 conditional `logger.info(...) if master_debug else logger.debug(...)` calls correctly replaced with unconditional `logger.debug(...)`. Since `master_debug` was hardcoded `True`, these were always taking the INFO branch — the fix is accurate. - `log_return_value()` correctly updated to `logger.debug` — previously this could log up to 300,000 chars of API response data at INFO level in production. - The `logger.warning("[ S N I P P E D ]")` sentinel at the end of `log_return_value` is intentionally kept at WARNING level to signal truncation. This is appropriate. - Dead commented-out code (`# if master_debug:` block in `log_return_value`) cleanly removed. - PR description accurately describes all changes made. #### Security - Minor improvement: API payloads and response bodies were previously logged at INFO level in production. Downgrading to DEBUG means sensitive payload data no longer appears in production logs by default. #### Style & Conventions - No issues. Clean, minimal change consistent with existing patterns. #### Suggestions - None. The fix is tightly scoped and complete. ### Verdict: APPROVED Straightforward, correct fix. Removes a hardcoded debug flag that was causing verbose API logging at INFO level in production. All 6 log-level changes (5 inline + `log_return_value`) are correct, dead code is cleaned up, and the behavioral change is exactly as described. > Note: Gitea does not allow self-approval. Verdict is APPROVED — no blocking issues found. --- *Automated review by Claude PR Reviewer*
cal added
ai-reviewed
and removed
ai-reviewing
labels 2026-03-05 10:46:49 +00:00
cal changed target branch from main to next-release 2026-03-07 07:32:31 +00:00
cal force-pushed ai/paper-dynasty-discord-28 from 56fe8a6099 to 9d1993bf49 2026-03-07 07:33:42 +00:00 Compare
cal merged commit 1c3ef0935e into next-release 2026-03-07 07:43:42 +00:00
cal deleted branch ai/paper-dynasty-discord-28 2026-03-07 07:43:43 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#58
No description provided.