Skip to content

fix: downgrade BrokenPipeError ping log from ERROR to WARNING#54

Open
palantir-valiot[bot] wants to merge 1 commit into
mainfrom
pulse/log-agent-fix-downgrade-brokenpipeerror-ping-log-f-20260501174059
Open

fix: downgrade BrokenPipeError ping log from ERROR to WARNING#54
palantir-valiot[bot] wants to merge 1 commit into
mainfrom
pulse/log-agent-fix-downgrade-brokenpipeerror-ping-log-f-20260501174059

Conversation

@palantir-valiot
Copy link
Copy Markdown

Automated Fix Proposal

🟢 High confidence

Bug

Recurring BrokenPipeError in pygqlc WebSocket ping thread (_ping_pong). When the WSS pipe breaks during a ping, the code catches the exception, sets wss_conn_halted = True, and the connection self-heals via the reconnection loop in _sub_routing_loop. However, it logs at ERROR level, creating alert noise.

Fix

Catch BrokenPipeError/OSError explicitly in _ping_pong and log at WARNING level, consistent with the existing _unsubscribe method which already handles the same exception at WARNING:

# _unsubscribe (existing pattern)
except BrokenPipeError as e:
    log(LogLevel.WARNING, 'WSS Pipe broken, nothing to stop')

The _ping_pong method now follows the same pattern:

except (BrokenPipeError, OSError):
    if not self.closing:
        log(LogLevel.WARNING, 'WSS Pipe broken, nothing to ping')
        self.wss_conn_halted = True

Other unexpected exceptions continue to log at ERROR.

Error context

  • Service: lamosa-gto-services-workflows (lamosa-gto:prod)
  • Error Hash: 97878975
  • Recurring: 8× in 1h
  • Stacktrace: pygqlc/GraphQLClient.py:723self._conn.send(PING_JSON)BrokenPipeError: [Errno 32] Broken pipe

Original Error

error trying to send ping, WSS Pipe is broken
BrokenPipeError: [Errno 32] Broken pipe
  File "/usr/src/app/.venv/lib/python3.14/site-packages/pygqlc/GraphQLClient.py", line 723, in _ping_pong
    self._conn.send(PING_JSON)

🤖 This PR was automatically generated by the Pulse Log Agent.
Human review required before merging.

Copy link
Copy Markdown
Author

@palantir-valiot palantir-valiot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Functional Change

The downgrade of BrokenPipeError (and OSError) ping logs from ERROR to WARNING is correct and appropriate. It aligns with the existing _unsubscribe pattern and correctly reduces alert noise for an expected, self-healing failure path. Other unexpected exceptions continue to log at ERROR, which is the right behavior.

Issue Found

Severity Finding
Minor Docstring bracket imbalance — the "fix" on line 7 adds an extra ], changing ]] to ]]]. The original was already balanced (3 [ and 3 ]), so the change introduces a syntax error in the docstring.

Minor Note

Catching OSError in _ping_pong is slightly broader than the existing _unsubscribe method (which catches only BrokenPipeError). In practice this is unlikely to cause issues since self._conn.send() is not expected to raise non-connection OSError subclasses, but it is a minor inconsistency with the existing pattern cited in the PR description.

Recommendation

Revert the docstring bracket change (remove the extra ]) before merging.

Comment thread pygqlc/GraphQLClient.py

GQLResponse (type variable): [data[field(string)], errors[message(string),
field?(string)]
field?(string)]]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docstring change introduces an extra ]. The original ]] was balanced — [data[field(string)], errors[message(string), field?(string)]] has 3 opening and 3 closing brackets. The new ]]] has 4 closing brackets, making it unbalanced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants