Skip to content

Fix nil-DataPoint crash masking real errors in ResqueJobs::RunSimulateDataPoint#853

Merged
brianlball merged 1 commit into
developfrom
fix/846-nil-datapoint-rescue
Jul 22, 2026
Merged

Fix nil-DataPoint crash masking real errors in ResqueJobs::RunSimulateDataPoint#853
brianlball merged 1 commit into
developfrom
fix/846-nil-datapoint-rescue

Conversation

@brianlball

Copy link
Copy Markdown
Contributor

Problem

Both rescue clauses in ResqueJobs::RunSimulateDataPoint.perform call d.add_to_rails_log on a nil d, raising NoMethodError: undefined method 'add_to_rails_log' for nil — masking the root cause in the Resque failed queue and leaving the datapoint permanently stuck in its prior status (#846, observed at k8s/KEDA scale with ~1,500+ workers).

Two distinct paths get there (raise_not_found_error: false in every env in mongoid.yml):

  1. Datapoint deleted between enqueue and perform → find returns nil (no DocumentNotFound) → d.get_statuses raises the first NoMethodError → rescue raises the second (the one Resque records)
  2. Transient Mongo failure under load → find itself raises → d never bound → same rescue crash

Change

  • Explicit nil check after find: log SKIPPING <id>: DataPoint no longer exists and return
  • Both rescues: when d is nil, log via Rails.logger.error with the datapoint id and re-raise the original error so the failed queue records the root cause; when d is bound, behavior unchanged (log to datapoint, swallow)

Test

Regression specs added to resque_run_simulate_data_point_hardening_spec.rb — written first and verified red on develop (both reproduce the masking NoMethodError), green after the fix (11 examples, 0 failures, run locally against mongod). Resque::* error consts are stubbed when the gem is absent so the spec runs outside the docker stack (resque is not bundled on Windows).

Fixes #846. Supersedes #850.

🤖 Generated with Claude Code

…eDataPoint (#846, #848)

- find returns nil for deleted DP (raise_not_found_error=false in all envs): skip cleanly w/ logged id instead of NoMethodError
- rescue clauses: when d never bound (transient Mongo failure in find), log w/ id and re-raise original so Resque failed queue records root cause, not masking NoMethodError
- regression specs reproduce both paths; Resque::* consts stubbed when gem absent (Windows)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@brianlball
brianlball merged commit 191c9aa into develop Jul 22, 2026
4 checks passed
@brianlball
brianlball deleted the fix/846-nil-datapoint-rescue branch July 22, 2026 20:45
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.

NoMethodError on nil DataPoint masks real failure in ResqueJobs::RunSimulateDataPoint#perform under load

1 participant