Repository navigation
Raise UndiscardableError from ClaimedExecution's class methods - #828
Merged
Merged
Conversation
ClaimedExecution.discard_all_in_batches and .discard_all_from_jobs raise UndiscardableError from inside `class << self`, where Ruby looks the constant up in the singleton class's lexical scope and ancestors. Neither has Execution::UndiscardableError, so both raised NameError (uninitialized constant #<Class:SolidQueue::ClaimedExecution>::UndiscardableError) instead of the intended error. Name the constant fully.
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.
ClaimedExecution.discard_all_in_batchesandClaimedExecution.discard_all_from_jobsare meant to refuse withSolidQueue::Execution::UndiscardableError, as the instance method#discarddoes. Both are defined insideclass << self, though, and there Ruby looksUndiscardableErrorup in the singleton class's lexical scope (#<Class:SolidQueue::ClaimedExecution>, thenSolidQueue) and the singleton class's ancestors. None of those holds the constant, which lives onSolidQueue::Execution, so both methods raiseNameErrorinstead:The same lookup, reduced (Ruby 3.3 and 4.0):
This names the constant fully in both class methods, and adds a test that each raises
SolidQueue::Execution::UndiscardableError. The instance method#discardis unaffected: its lookup reachesExecutionthroughClaimedExecution's own ancestors.I could not run the full suite locally (its development dependencies need MySQL and PostgreSQL client libraries), so the new test is left to CI.