Skip to content

Fix Message failed: ' Timeout' SWARN in SHTTPSManager::postPoll#2562

Open
Beamanator wants to merge 5 commits intomainfrom
claude-fix-message-timeout-warn
Open

Fix Message failed: ' Timeout' SWARN in SHTTPSManager::postPoll#2562
Beamanator wants to merge 5 commits intomainfrom
claude-fix-message-timeout-warn

Conversation

@Beamanator
Copy link
Copy Markdown
Contributor

@Beamanator Beamanator commented Mar 27, 2026

Explanation of Change

SHTTPSManager::postPoll() was only calling _onRecv() for responses containing " 200", "204", or "202" in the methodLine, or responses with body content. Any other complete response (including non-standard methodLines like " Timeout" from load balancers) fell into an else branch that fired SWARN("Message failed: '...") and coerced the response to 500.

The existing code comment even called this out explicitly: "Coercing anything that's not 200 to 500 makes no sense, and should be abandoned with the above."

Before: Non-standard HTTP responses (e.g., load balancer returning " Timeout" instead of HTTP/1.1 504 Gateway Timeout) triggered SWARN("Message failed: '...'") and forced response=500, bypassing all _onRecv() subclass handling.

After: All complete responses are passed to _onRecv() for proper subclass handling. Non-standard methodLines (not starting with HTTP/) log at SHMMM severity instead of SWARN. Subclasses (Stripe, Hubspot, etc.) parse response codes as designed.

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/610175

Tests

Added testGetHTTPResponseCode to LibStuffTest verifying:

  • Standard HTTP responses (200, 204, 202, 400, 500, 504) parse correctly
  • Non-standard methodLines (" Timeout", "Timeout", "") return 400 as a safe default
  • Explicit defaultStatusCode parameter is used when parsing fails

Internal Testing Reminder: when changing bedrock, please compile auth against your new changes

Remove the broken 200/204/202 check that prevented _onRecv() from being
called for valid non-2xx responses. Any complete HTTP response should be
passed to the subclass for handling — the existing comment explicitly
noted this logic was wrong. Non-standard methodLines (e.g., a load
balancer returning " Timeout" instead of a proper HTTP status line) now
log at SHMMM severity instead of firing a SWARN and coercing the
response to 500.

Fixes: Expensify/Expensify#610175

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Preserved the fix: remove the restrictive 200/204/202 check and call
_onRecv() for all complete responses. Non-standard methodLines log at
SHMMM instead of SWARN.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Beamanator
Copy link
Copy Markdown
Contributor Author

@codex review

@Beamanator
Copy link
Copy Markdown
Contributor Author

@MelvinBot review this PR

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Verify that the caller-specified fallback code is respected when the
methodLine cannot be parsed as a valid HTTP status.

Made-with: Cursor
@Beamanator
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4f5923972

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread libstuff/SHTTPSManager.cpp
Beamanator and others added 2 commits April 10, 2026 14:56
The comment stated 'if we fail to find such a code, or can't parse it
as an integer, we default to 400' but the code left transaction.response
at 0. This made wait loops like 'while (!transaction->response)' stall
on non-standard method lines (e.g. ' Timeout').

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e empty

If SParseHTTP returns nonzero bytes but leaves methodLine empty (e.g.
a bare CRLF response), _onRecv was skipped, leaving transaction.response==0
and stalling any 'while (!transaction->response)' wait loop.

Also clarify in comment that non-standard responses (no Content-Length,
unparseable status) only reach completeRequest=true once the socket closes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Beamanator
Copy link
Copy Markdown
Contributor Author

@codex review

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.

1 participant