{"record":{"id":"2d949b24b1663685","repo":"bensheldon/good_job","slug":"must-provide-a-block","errorCode":null,"errorMessage":"Must provide a block","messagePattern":"Must provide a block","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"app/models/concerns/good_job/advisory_lockable.rb","lineNumber":386,"sourceCode":"          cte_query = cte_query.limit(select_limit) if select_limit\n          cte_type = supports_cte_materialization_specifiers? ? :MATERIALIZED : :\"\"\n          composed_cte = Arel::Nodes::As.new(cte_table, Arel::Nodes::UnaryOperation.new(cte_type, cte_query.arel))\n\n          lock_condition = \"#{function}(#{advisory_lock_bigint_sql(\"#{_quoted_table_name_string} || '-' || #{adapter_class.quote_table_name(cte_table.name)}.#{adapter_class.quote_column_name(column)}::text\")})\"\n          query = cte_table.project(cte_table[:id])\n                           .with(composed_cte)\n                           .where(defined?(Arel::Nodes::BoundSqlLiteral) ? Arel::Nodes::BoundSqlLiteral.new(lock_condition, [], {}) : Arel::Nodes::SqlLiteral.new(lock_condition))\n\n          limit = original_query.arel.ast.limit\n          query.limit = limit.value if limit.present?\n\n          unscoped.where(Arel::Nodes::InfixOperation.new(\"IN\", arel_table[primary_key], query)).merge(original_query.only(:order))\n        end\n      end\n\n      # @deprecated Use {.advisory_lock} with a block instead.\n      def with_advisory_lock(**kwargs, &block)\n        raise ArgumentError, \"Must provide a block\" unless block\n\n        advisory_lock(**kwargs, &block)\n      end\n\n      # Acquires an advisory lock on this record if it is not already locked by\n      # another database session. Be careful to ensure you release the lock when\n      # you are done with {#advisory_unlock_key} to release all remaining locks.\n      # @param key [String, Symbol] Key to Advisory Lock against\n      # @param function [String, Symbol] Postgres Advisory Lock function name to use\n      # @return [Boolean] whether the lock was acquired.\n      def advisory_lock_key(key, function: advisory_lockable_function, connection: nil)\n        query = if function.include? \"_try_\"\n                  <<~SQL.squish\n                    SELECT #{function}(#{advisory_lock_bigint_sql('$1::text')}) AS locked\n                  SQL\n                else\n                  <<~SQL.squish\n                    SELECT #{function}(#{advisory_lock_bigint_sql('$1::text')})::text AS locked","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/bensheldon/good_job/blob/5fcde48f8765e69901ffa9c5a06122b19c73875f/app/models/concerns/good_job/advisory_lockable.rb#L368-L404","documentation":"Error \"Must provide a block\" thrown in bensheldon/good_job.","triggerScenarios":"Thrown at app/models/concerns/good_job/advisory_lockable.rb:386 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call the advisory lock method with a block; the lock is held only for the duration of the block.","Pass a block to with_advisory_lock."],"exampleFix":"record.with_advisory_lock do\n  # work under the lock\nend","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5fcde48f8765e69901ffa9c5a06122b19c73875f","analyzedAt":"2026-08-23T14:55:11.399Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}