Skip to content

Fix NoMethodError when thread replies enabled and HTTP request fails#3

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775813460-fix-nil-response-crash
Open

Fix NoMethodError when thread replies enabled and HTTP request fails#3
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775813460-fix-nil-response-crash

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 10, 2026

Summary

Adds a safe navigation guard (&.) when extracting the thread root ID from the HTTP response in the notify_started Capistrano task.

Chatopsify::Co#process rescues errors internally and returns nil. When chatops_use_thread_replies is enabled and the HTTP request fails (network error, non-JSON response, etc.), response is nil and response.dig('id') raises a NoMethodError. This masks the real underlying error in the Capistrano log output.

The fix: response.dig('id')response&.dig('id'), so a failed request results in chatops_root_id being set to nil (subsequent notifications simply won't be threaded) rather than raising a misleading exception.

Review & Testing Checklist for Human

  • Confirm that silently setting chatops_root_id to nil on request failure is acceptable behavior — an alternative would be to skip the set entirely or log a warning when the response is nil
  • Verify the analogous response&.dig pattern isn't needed elsewhere (the notify_finished and notify_failed tasks don't call .dig on a response, so they're fine)

Notes

The outer rescue StandardError in the task already prevents deploy crashes, but without this fix the logged error is NoMethodError: undefined method 'dig' for nil:NilClass instead of the actual HTTP/network error — making debugging harder.

Link to Devin session: https://app.devin.ai/sessions/a859da5343784f55b4d9bf2b84c9f50d
Requested by: @papakvy


Open with Devin

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>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin 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