feat(mattermost): add retry logic and timeout handling for DM channel creation#42398
Conversation
Greptile SummaryThis PR adds All nine issues raised in the previous review rounds have been resolved:
One design point from the previous round (full replacement via Confidence Score: 4/5
Last reviewed commit: eaaf224 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c177c1dee8
ℹ️ 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".
|
@greptile-apps Thanks for the thorough review! All four issues have been addressed in commit
Also added 3 new tests to verify the 4xx false positive fixes and AbortSignal propagation. |
|
Perfect! All four issues are properly fixed: 1. timeoutMs ✅ - AbortSignal is now correctly passed through the entire chain (client.ts:188-193, 169-173) 2. isRetryableError false positives ✅ - Two layers of protection:
3. onRetry callback ✅ - User callback is preserved and called before logging (send.ts:176-177) 4. initialDelayMs validation ✅ - Zod refinement with clear error message (config-schema.ts:17-25) The new tests comprehensively cover the edge cases. Nice work! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a2391953e
ℹ️ 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".
|
关闭原因:发现多个严重 bug 需要重新设计
请修复后重新提交。 |
🔴 发现严重问题,建议关闭此 PR关键 Bug:
建议重新设计后再提交。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a85603cbee
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9479396f7b
ℹ️ 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".
|
@greptile review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eaaf224cd6
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df9cf76f92
ℹ️ 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".
df9cf76 to
a3149db
Compare
a3149db to
540a380
Compare
… creation Adds exponential backoff retry mechanism for Mattermost DM channel creation to handle transient failures (429, 5xx, network errors). Changes: - Add createMattermostDirectChannelWithRetry() with configurable retry options - Support maxRetries, initialDelayMs, maxDelayMs, timeoutMs parameters - Add dmChannelRetry config option to Mattermost account schema - Allow per-send override via dmRetryOptions in MattermostSendOpts - Add comprehensive tests for retry logic and error handling - Retry on: 429 rate limits, 5xx server errors, network/transient errors - Don't retry on: 4xx client errors (except 429) Fixes the gap identified in PR openclaw#29925 where initial DM channel creation failures had no retry mechanism.
- Fix timeoutMs: pass AbortSignal to createMattermostDirectChannel and fetch - Fix isRetryableError false positives: check for explicit 4xx status codes before falling back to network pattern matching - Fix onRetry callback: preserve user's callback while adding logging - Add Zod schema refinement: validate initialDelayMs <= maxDelayMs - Add tests for 4xx false positive cases and AbortSignal propagation
…and jitter - Fix isRetryableError: check 5xx BEFORE 4xx to prevent misclassification when 5xx error detail contains 4xx substring (e.g., '503: upstream 404') - Fix jitter: use proportional jitter (full-jitter pattern) instead of hardcoded 1000ms. Jitter is now 0-100% of exponential delay - Update tests to reflect new jitter behavior - Add test for 5xx with 4xx substring in error message
Add missing dmChannelRetry field to TypeScript type definition in types.ts to match the Zod schema in config-schema.ts. Fixes type checking error when accessing account.config.dmChannelRetry.
- Fix isRetryableError: use 'mattermost api NNN' prefix pattern instead of
\b\d{3}\b to avoid matching port numbers (e.g., :443) and IP octets
- Fix timeout test: properly verify AbortController aborts the fetch by
listening to the abort event on the signal
- Add test for port 443 connection errors to verify no false 4xx classification
- Update error messages in tests to use 'Mattermost API NNN' format
- Fix isRetryableError: check 'mattermost api 429' status code BEFORE generic '429' text match to avoid false positives - Error messages containing '429' in detail (e.g., 'Invalid ID: 4294967295') are no longer incorrectly treated as rate limiting - Add test for 400 error containing '429' text to verify no false retry
540a380 to
3db47be
Compare
|
Merged via squash.
Thanks @JonathanJing! |
* main: (142 commits) fix(zalouser): fix setup-only onboarding flow (openclaw#49219) CI: add built plugin singleton smoke (openclaw#48710) update contributing focus areas docs(providers): clarify provider capabilities vs public capability model docs(refactor): align plugin SDK plan with public capability model docs(cli): add plugins inspect command reference docs(plugins): document public capability model, plugin shapes, and inspection Plugins: internalize diagnostics OTel imports Plugins: internalize diffs SDK imports Plugins: internalize more extension SDK imports Plugins: add local extension API barrels Plugins: add inspect matrix and trim export Plugins: add inspect command and capability report fix(telegram): unify transport fallback chain (openclaw#49148) Plugins: add binding resolution callbacks (openclaw#48678) fix(gateway): clear trusted-proxy control ui scopes refactor: narrow extension public seams test: stabilize memory async search close docs(hooks): clarify trust model and audit guidance feat(mattermost): add retry logic and timeout handling for DM channel creation (openclaw#42398) ...
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm (cherry picked from commit 2145eb5)
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm (cherry picked from commit 2145eb5)
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm (cherry picked from commit 2145eb5)
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm (cherry picked from commit 2145eb5)
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm (cherry picked from commit 2145eb5)
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm (cherry picked from commit 2145eb5)
… creation (openclaw#42398) Merged via squash. Prepared head SHA: 3db47be Co-authored-by: JonathanJing <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
Summary
Adds exponential backoff retry mechanism for Mattermost DM channel creation to handle transient failures (429, 5xx, network errors).
Problem
PR #29925 introduced user-first resolution for DM media uploads, but the initial DM channel creation has no retry mechanism. If the first attempt fails due to transient errors (rate limiting, temporary server issues), the send operation fails immediately.
Solution
createMattermostDirectChannelWithRetry()with configurable retry optionsmaxRetries,initialDelayMs,maxDelayMs,timeoutMsparametersdmChannelRetryconfig option to Mattermost account schemadmRetryOptionsinMattermostSendOptsRetry Behavior
maxDelayMsConfiguration Example
Testing
Review Status
Greptile Review: All 4 issues identified in the initial review have been addressed in commit
8a23919:timeoutMsnow properly passes AbortSignal to fetchisRetryableErrorno longer has false positives on 4xx errorsonRetrycallback is preserved and called alongside logginginitialDelayMs <= maxDelayMsCloses the gap identified in PR #29925.