Git Product home page Git Product logo

Comments (15)

rikkipitt avatar rikkipitt commented on August 29, 2024 1

I just created a really basic job that works with perform_now but not perform_later on Heroku:

# frozen_string_literal: true

class TestJob < ApplicationJob
  queue_as :default

  def perform(company_id)
    company = Company.find(company_id)

    puts company.uid
  end
end

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024 1

Hi @vishaldeepak, good question! I think I probably ended up just using the built in Rails encryption if I remember correctly!

https://guides.rubyonrails.org/active_record_encryption.html

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024

The model:

# frozen_string_literal: true

class Company < ApplicationRecord
  crypt_keeper :refresh_token, :short_code, :uid,
               encryptor: :active_support,
               key: Rails.application.secrets.company_encryption_key,
               salt: Rails.application.secrets.company_encryption_salt
end

from crypt_keeper.

jmazzi avatar jmazzi commented on August 29, 2024

@rikkipitt can you provide a backtrace of the error you're seeing?

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024

@jmazzi thanks for the swift reply, please see below. This is the error from Heroku:

ActiveSupport::MessageEncryptor::InvalidMessage
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/message_encryptor.rb:190:in `_decrypt'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
/app/vendor/bundle/ruby/2.5.0/gems/crypt_keeper-2.0.1/lib/crypt_keeper/provider/active_support.rb:36:in `decrypt'
/app/vendor/bundle/ruby/2.5.0/gems/crypt_keeper-2.0.1/lib/crypt_keeper/provider/base.rb:16:in `load'
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/type/serialized.rb:22:in `deserialize'
/app/vendor/bundle/ruby/2.5.0/gems/activemodel-5.2.2/lib/active_model/attribute.rb:165:in `type_cast'
/app/vendor/bundle/ruby/2.5.0/gems/activemodel-5.2.2/lib/active_model/attribute.rb:42:in `value'
/app/vendor/bundle/ruby/2.5.0/gems/activemodel-5.2.2/lib/active_model/attribute_set.rb:48:in `fetch_value'
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/attribute_methods/read.rb:77:in `_read_attribute'
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.2/lib/active_record/attribute_methods/read.rb:40:in `__temp__3786f62747f536f64656'
/app/app/models/xero.rb:46:in `block (3 levels) in invoices_due_on'
/app/app/models/xero.rb:44:in `each'
/app/app/models/xero.rb:44:in `block (2 levels) in invoices_due_on'
/app/app/models/xero.rb:15:in `block in all_invoices'
/app/vendor/bundle/ruby/2.5.0/bundler/gems/xeroizer-6a4107641bd7/lib/xeroizer/record/base_model.rb:133:in `find_in_batches'
/app/app/models/xero.rb:14:in `all_invoices'
/app/app/models/xero.rb:43:in `block in invoices_due_on'
/app/app/models/xero.rb:42:in `tap'
/app/app/models/xero.rb:42:in `invoices_due_on'
/app/app/jobs/notify_slack_channel_job.rb:8:in `perform'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:39:in `block in perform_now'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/i18n-1.5.3/lib/i18n.rb:284:in `with_locale'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/translation.rb:9:in `block (2 levels) in <module:Translation>'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `instance_exec'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:26:in `block (4 levels) in <module:Logging>'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `block in instrument'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `instrument'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:25:in `block (3 levels) in <module:Logging>'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:46:in `block in tag_logger'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `block in tagged'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:28:in `tagged'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/tagged_logging.rb:71:in `tagged'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:46:in `tag_logger'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/logging.rb:22:in `block (2 levels) in <module:Logging>'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `instance_exec'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:136:in `run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:38:in `perform_now'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:24:in `block in execute'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/railtie.rb:28:in `block (4 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/execution_wrapper.rb:87:in `wrap'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/reloader.rb:73:in `block in wrap'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/execution_wrapper.rb:87:in `wrap'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/reloader.rb:72:in `wrap'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/railtie.rb:27:in `block (3 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `instance_exec'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/callbacks.rb:136:in `run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/execution.rb:22:in `execute'
/app/vendor/bundle/ruby/2.5.0/gems/activejob-5.2.2/lib/active_job/queue_adapters/delayed_job_adapter.rb:42:in `perform'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/backend/base.rb:81:in `block in invoke_job'
/app/vendor/bundle/ruby/2.5.0/gems/honeybadger-4.2.1/lib/honeybadger/plugins/delayed_job/plugin.rb:37:in `block (2 levels) in <class:Plugin>'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:79:in `block (2 levels) in add'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:61:in `block in initialize'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:79:in `block in add'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:66:in `execute'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/backend/base.rb:78:in `invoke_job'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:230:in `block (2 levels) in run'
/app/vendor/ruby-2.5.3/lib/ruby/2.5.0/timeout.rb:93:in `block in timeout'
/app/vendor/ruby-2.5.3/lib/ruby/2.5.0/timeout.rb:103:in `timeout'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:230:in `block in run'
/app/vendor/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:229:in `run'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:312:in `block in reserve_and_run_one_job'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:61:in `block in initialize'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:66:in `execute'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:312:in `reserve_and_run_one_job'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:213:in `block in work_off'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:212:in `times'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:212:in `work_off'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:175:in `block (4 levels) in start'
/app/vendor/ruby-2.5.3/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:174:in `block (3 levels) in start'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:61:in `block in initialize'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:66:in `execute'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:173:in `block (2 levels) in start'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:172:in `loop'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:172:in `block in start'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:79:in `block (2 levels) in add'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:61:in `block in initialize'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:79:in `block in add'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:66:in `execute'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/worker.rb:171:in `start'
/app/vendor/bundle/ruby/2.5.0/gems/delayed_job-4.1.5/lib/delayed/tasks.rb:9:in `block (2 levels) in <main>'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `block in execute'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `each'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `execute'
/app/vendor/bundle/ruby/2.5.0/gems/airbrake-7.4.0/lib/airbrake/rake.rb:17:in `execute'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:183:in `invoke'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:160:in `invoke_task'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:116:in `each'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:116:in `block in top_level'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:125:in `run_with_threads'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:110:in `top_level'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:83:in `block in run'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/app/vendor/bundle/ruby/2.5.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.5.0/bin/rake:23:in `<top (required)>'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `load'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:27:in `run'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli.rb:360:in `exec'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli.rb:20:in `dispatch'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli.rb:10:in `start'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/exe/bundle:30:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>'
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024

Where xero.rb is an STI class of company.rb. E.g.

# frozen_string_literal: true

class Xero < Company
end

from crypt_keeper.

jmazzi avatar jmazzi commented on August 29, 2024

@rikkipitt ok, thanks. I've never used active_support with crypt_keeper. It's not something it directly supports, even if it is working ok most of the time.

Does the exception happen if you run .perform in a Heroku console in production? Have you verified that ENV['KEY'] is the value you expect?

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024

Oh right, which strategy do you normally use? If I do a direct call to the job with perform_now from the Heroku rails console, it works...

from crypt_keeper.

jmazzi avatar jmazzi commented on August 29, 2024

@rikkipitt that would indicate an issue with delayed_job, not crypt_keeper

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024

D'oh. Sorry, @jmazzi. Strange that it works locally. I'll have to dig further into this.

from crypt_keeper.

jmazzi avatar jmazzi commented on August 29, 2024

@rikkipitt try logging the KEY and Message to a file when the job is called, see if either of them are blank or unexpected.

Don't forget to remove the log file!

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024

@jmazzi I can confirm that the key/salt is loaded and as expected...

from crypt_keeper.

jmazzi avatar jmazzi commented on August 29, 2024

@rikkipitt have you tried logging them from the job itself? I.e. in the perform method?

from crypt_keeper.

rikkipitt avatar rikkipitt commented on August 29, 2024

@jmazzi I did indeed and they were present and correct.

from crypt_keeper.

vishaldeepak avatar vishaldeepak commented on August 29, 2024

@rikkipitt were you able to resolve it, I have the same problem but when using rake task.

from crypt_keeper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.