d devhelper

← All errors

Code bug

NoMethodError

undefined method 'program' for nil program_settings = member_program.program.program_settings ^^^^^^^^

TextMessageRequestJob@support_request2 events · 0 users first seen 12 d agolast seen 8 h ago

In one line

The text-message job crashes when a member has no member program, because `assignable_support_request_id_with_class_name` never checks for nil.

Checked against the code

What happened

  • `assignable_support_request_id_with_class_name` sets `member_program` from `member_program_for_care_extender(...) || member.recent_program`, and both can be nil.
  • It then calls `member_program.program` without a nil check, so it raises NoMethodError.
  • The sibling method `update_sentiment` already handles nil `member_program` with a guard and an error log. This method has no such guard.
  • There were only 8 events in 12 days, so this is a few members with no program, not a failure on every message.

What to do next

  1. Code fix In app/models/text_message.rb, in assignable_support_request_id_with_class_name, add `return [nil, nil] unless member_program&.program` right after the member_program assignment (line 192). The job already returns early when request_id is nil.
  2. Query Lists members with text rooms but no member program, which should match the few failing events.
    SELECT m.id, m.created_at FROM members m WHERE NOT EXISTS (SELECT 1 FROM member_programs mp WHERE mp.member_id = m.id) AND EXISTS (SELECT 1 FROM text_rooms tr WHERE tr.member_id = m.id) LIMIT 50;

Queries are shown, never run. Check them before using them on production.

Ask a follow-up

Continues the same session, so it still remembers the error and the code it read.

Enter to send · Shift+Enter for a new line
Analysed 1 h ago · claude-sonnet-5-5 · $0.03