{"record":{"id":"401079a29f2d91ac","repo":"instructure/canvas-lms","slug":"there-is-no-event-name-to-sym-defined-for-the-current-state","errorCode":null,"errorMessage":"There is no event #{name.to_sym} defined for the #{current_state} state","messagePattern":"There is no event #(.+?) defined for the #(.+?) state","errorType":"exception","errorClass":"NoTransitionAllowed","httpStatus":null,"severity":"error","filePath":"gems/workflow/lib/workflow.rb","lineNumber":193,"sourceCode":"      @halted_because\n    end\n\n    # INSTRUCTURE:\n    def process_event(name, *)\n      success = true\n      begin\n        process_event!(name, *)\n      rescue NoTransitionAllowed\n        @halted = true\n        @halted_because = $!\n        success = false\n      end\n      success\n    end\n\n    def process_event!(name, *)\n      event = current_state.events[name.to_sym]\n      raise NoTransitionAllowed, \"There is no event #{name.to_sym} defined for the #{current_state} state\" if event.nil?\n\n      @halted_because = nil\n      @halted = false\n      @raise_exception_on_halt = false\n      return_value = run_action(event.action, *) || run_action_callback(\"do_#{event.name}\", *)\n      if @halted\n        if @raise_exception_on_halt\n          raise TransitionHalted, @halted_because\n        else\n          false\n        end\n      else\n        run_on_transition(current_state, spec.states[event.transitions_to], name, *)\n        transition(current_state, spec.states[event.transitions_to], name, *)\n        return_value\n      end\n    end\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/gems/workflow/lib/workflow.rb#L175-L211","documentation":"The workflow gem's process_event! raises NoTransitionAllowed when the requested event name is not defined on the object's current state. State machines have per-state event maps; calling an event that exists on other states but not this one is invalid.","triggerScenarios":"Calling obj.process_event!(:approve) when the current_state has no :approve event (e.g. approving an already-approved record); invoking events on records in terminal states; calling events in the wrong lifecycle order.","commonSituations":"Race conditions where two requests transition the same record and the second sees an updated state; stale UI data showing buttons for events no longer valid; missing state in a newly added workflow step.","solutions":["Check the valid events for the current state before calling (current_state.events.key?(name)) or use the non-bang process_event which returns false instead of raising","Reload the record to get the freshest state before transitioning","Guard the UI to only render valid events for the record's state","Rescue NoTransitionAllowed and handle the stale-transition case gracefully"],"exampleFix":"// before\nrecord.process_event!(:publish)\n// after\nif record.current_state.events.key?(:publish)\n  record.process_event!(:publish)\nelse\n  Rails.logger.warn(\"publish not valid in #{record.current_state}\")\nend","handlingStrategy":"try-catch","validationCode":"if obj.current_state.events.key?(event_name)\n  obj.process_event!(event_name)\nend","typeGuard":null,"tryCatchPattern":"begin\n  obj.process_event!(event_name)\nrescue Workflow::NoTransitionAllowed\n  Rails.logger.warn(\"#{event_name} invalid in #{obj.current_state}\")\n  obj.reload\nend","preventionTips":["Reload records before transitions in concurrent flows","Only render UI actions valid for the current state","Prefer the non-bang process_event when raising is undesired","Document per-state event maps for custom workflows"],"tags":["workflow","state-machine","ruby"],"backgroundTag":"invalid-state-transition","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}