Fix NoMethodError when thread replies enabled and HTTP request fails#3
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
Fix NoMethodError when thread replies enabled and HTTP request fails#3devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
When chatops_use_thread_replies is enabled and the initial HTTP request
fails, Chatopsify::Co#process catches the error and returns nil. The
subsequent call to response.dig('id') raises NoMethodError on nil,
masking the real error.
Use safe navigation operator (response&.dig) to guard against nil
response, preventing the misleading NoMethodError.
Co-Authored-By: tamphubkdn <tamphubkdn@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a safe navigation guard (
&.) when extracting the thread root ID from the HTTP response in thenotify_startedCapistrano task.Chatopsify::Co#processrescues errors internally and returnsnil. Whenchatops_use_thread_repliesis enabled and the HTTP request fails (network error, non-JSON response, etc.),responseisnilandresponse.dig('id')raises aNoMethodError. This masks the real underlying error in the Capistrano log output.The fix:
response.dig('id')→response&.dig('id'), so a failed request results inchatops_root_idbeing set tonil(subsequent notifications simply won't be threaded) rather than raising a misleading exception.Review & Testing Checklist for Human
chatops_root_idtonilon request failure is acceptable behavior — an alternative would be to skip thesetentirely or log a warning when the response is nilresponse&.digpattern isn't needed elsewhere (thenotify_finishedandnotify_failedtasks don't call.digon a response, so they're fine)Notes
The outer
rescue StandardErrorin the task already prevents deploy crashes, but without this fix the logged error isNoMethodError: undefined method 'dig' for nil:NilClassinstead of the actual HTTP/network error — making debugging harder.Link to Devin session: https://app.devin.ai/sessions/a859da5343784f55b4d9bf2b84c9f50d
Requested by: @papakvy