Description
The nested _fetch_folder_rules() helper inside get_all_existing_rules() silently swallows httpx.HTTPError without any log output:
# main.py ~line 1588
def _fetch_folder_rules(folder_id: str) -> list[str]:
try:
data = _api_get(client, f"{API_BASE}/{profile_id}/rules/{folder_id}").json()
folder_rules = data.get("body", {}).get("rules", [])
return [rule["PK"] for rule in folder_rules if rule.get("PK")]
except httpx.HTTPError:
return [] # ← HTTP errors are silently dropped
except Exception as e:
log.warning(...) # generic errors DO log
return []
This means that if the API returns a 4xx/5xx for a specific folder's rules endpoint, the function returns an empty list with no indication to the operator. The outer function only logs for generic Exception, not for httpx.HTTPError.
This is distinct from issue #589, which targets the root-level except httpx.HTTPError: pass in the same function. This issue targets the per-folder inner helper.
Suggested Changes
- Add a
log.debug() call before return [] in the except httpx.HTTPError branch of _fetch_folder_rules:
except httpx.HTTPError as e:
log.debug("HTTP error fetching rules for folder %s: %s", folder_id, sanitize_for_log(e))
return []
- Use
log.debug (not log.warning) since transient folder errors are expected and shouldn't spam operators; debug level is sufficient for diagnostic purposes
- Add a unit test that verifies the debug log message is emitted when
_api_get raises httpx.HTTPError for a folder
Files Affected
main.py (~lines 1588-1601, _fetch_folder_rules nested function)
tests/ — add test for debug log on folder HTTP error
Success Criteria
_fetch_folder_rules emits a log.debug() message (including sanitized error and folder ID) when an httpx.HTTPError occurs
log.warning() is NOT used (avoid alarming operators for expected transient errors)
sanitize_for_log() wraps the exception in the log call
- Existing tests pass; new test verifies the debug log path
Source
Identified from discussion #586 QA analysis and code inspection. Related to open issue #589 (root-level silent HTTP error in the same function).
Priority
Low — improves debug-level observability for folder rule fetching; consistent with the logging improvements in issue #589.
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent
To install this agentic workflow, run
gh aw add github/gh-aw/.github/workflows/discussion-task-miner.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
Description
The nested
_fetch_folder_rules()helper insideget_all_existing_rules()silently swallowshttpx.HTTPErrorwithout any log output:This means that if the API returns a 4xx/5xx for a specific folder's rules endpoint, the function returns an empty list with no indication to the operator. The outer function only logs for generic
Exception, not forhttpx.HTTPError.This is distinct from issue #589, which targets the root-level
except httpx.HTTPError: passin the same function. This issue targets the per-folder inner helper.Suggested Changes
log.debug()call beforereturn []in theexcept httpx.HTTPErrorbranch of_fetch_folder_rules:log.debug(notlog.warning) since transient folder errors are expected and shouldn't spam operators; debug level is sufficient for diagnostic purposes_api_getraiseshttpx.HTTPErrorfor a folderFiles Affected
main.py(~lines 1588-1601,_fetch_folder_rulesnested function)tests/— add test for debug log on folder HTTP errorSuccess Criteria
_fetch_folder_rulesemits alog.debug()message (including sanitized error and folder ID) when anhttpx.HTTPErroroccurslog.warning()is NOT used (avoid alarming operators for expected transient errors)sanitize_for_log()wraps the exception in the log callSource
Identified from discussion #586 QA analysis and code inspection. Related to open issue #589 (root-level silent HTTP error in the same function).
Priority
Low — improves debug-level observability for folder rule fetching; consistent with the logging improvements in issue #589.