Not working with Rails 7.1

Feature(s) impacted

Accessing data

Observed behavior

After upgrading to Rails 7.1 I can’t access my data.

I get :

[2023-11-23 11:45:02 +0100] Forest 🌳🌳🌳  An error occured while retrieving your IP whitelist. Your Forest env_secret seems to be missing or unknown. Can you check that you properly set your Forest env_secret in the forest_liana initializer?

If I rollback to Rails 7.0.8 it works perfectly.

Expected behavior

I should see my data

Failure Logs

[2023-11-23 11:45:02 +0100] Forest 🌳🌳🌳  An error occured while retrieving your IP whitelist. Your Forest env_secret seems to be missing or unknown. Can you check that you properly set your Forest env_secret in the forest_liana initializer?

Context

  • Environment name: Rails in development
  • Agent (forest package) name & version: forest_liana (8.0.16) gem
  • Database type: postgresql
  • Recent changes made on your end if any: Upgrade to Rails 7.1

Hello @zaratan,

Thanks for reaching out :raised_hands:

Our team has tested rails version 7.1 without any issue.

Could you please:

  • Verify that you activated the cache configuration (rails dev:cache)
  • Clean the cache (rails tmp:cache:clear)

Let me know if those commands have any impact.
Thanks!

Hello @anon34731316 !

Thank you for your answer. I supposed that your team did test with Rails 7.1 as it is out for a while now.

I did rails dev:cache (twice). First answer was Development mode is no longer being cached. and the second one Development mode is now being cached. (which I believe is what we want). Then I did a rails tmp:cache:clear. Restarted the server and still got the same error.

It’s probably something on my side but I can’t se what. I had trouble with custom SmartActions and fields so I did this in config/application.rb but it shouldn’t change anything there…

Rails.autoloaders.main.ignore(
  Rails.root.join("lib/forest_liana"),
)

Do you have any other idea ?

1 Like

@zaratan,

Did you follow this migration note when upgrading?
Could you please share the result of that command rails zeitwerk:check?
And can you share the exact server logs you’re having when you’re trying to access your data?

Thanks.

1 Like

@anon34731316

Thanks for the quick answer.

As far as I know, I skimmed through the list and didn’t see anything relevant here. The rest of the app is working well.

The result of rails zeitwerk:check is :

Hold on, I am eager loading the application.

WARNING: The following directories will only be checked if you configure
them to be eager loaded:

/Users/zaratan/Projects/konnect/test/mailers/previews

You may verify them manually, or add them to config.eager_load_paths
in config/application.rb and run zeitwerk:check again.

Otherwise, all is good!

which should be ok for Forest purposes.

This is the log I see when trying to access my data :

Started GET “/admin/sidekiq/stats” for ::1 at 2023-11-23 16:20:42 +0100
User Load (2.4ms) SELECT “users”.* FROM “users” WHERE “users”.“id” = $1 ORDER BY “users”.“created_at” ASC, “users”.“id” ASC LIMIT $2 [[“id”, “cdadbf61-8f16-4290-b413-32555fa1c025”], [“LIMIT”, 1]]
Started POST “/forest/authentication” for ::1 at 2023-11-23 16:20:51 +0100
Processing by ForestLiana::AuthenticationController#start_authentication as /
Parameters: {“renderingId”=>“207252”}
[2023-11-23 16:20:51 +0100] Forest :deciduous_tree::deciduous_tree::deciduous_tree: An error occured while retrieving your IP whitelist. Your Forest env_secret seems to be missing or unknown. Can you check that you properly set your Forest env_secret in the forest_liana initializer?
Filter chain halted as :reject_unauthorized_ip rendered or redirected
Completed 403 Forbidden in 172ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 1738)

Hi @zaratan,

I’am not able to reproduce your issue on my side.

I’ve tried to upgrade a rails 7.0 to 7.1 and a rails 6.1 to 7.1 and both work.

Could you try to deactivated the IP Whitelist feature. (In Project Settings → Security)

1 Like

Hi @nicolasa !

Thanks for your help !

Our account is on team plan (marketing discussions are in progress for upgrading but they are not done yet) so I can’t see the “security” panel in settings.

I’ll try adding debugger breakpoints into Forest gem on Monday to investigate further and understand where the issue comes from but this will be a long process.

In the mean time, if you have any idea of anything else to test or a place where I should break in the gem (Saving me some reading/debug time), that would be awesome !

D.

The error occured when the gem try to fetch the Ip WhiteList rules in this file.

You can add a breakpoint here to check what was the value of response var.

1 Like

The error I get from the response is :
Status : 422
Body :

{
  "errors": [
    {
      "status": 422,
      "detail": "Missing or invalid secretKey in the request is unprocessable",
      "meta": {
        "entityName": "Missing or invalid secretKey in the request"
       },
       "name": "InvalidSecretKeyError"
    }
  ]
}

I went down a bit lower into the rabbit hole with some extra breakpoints and the issue was indeed on my side. I’ve missed a migration from secrets (which forest installer uses/creates and are now deprecated in Rails 7.1) to credentials.

Thanks a lot for your help and sorry for the time it took you :sweat_smile:

1 Like

If anyone stumble here at a later time while upgrading to a rails version not supporting secrets anymore. This is my initializer :

config/initializers/forest_liana.rb

ForestLiana.env_secret =
  ENV.fetch(
    "FOREST_ENV_SECRET",
    Rails.application.credentials.forest_env_secret,
  )
ForestLiana.auth_secret =
  ENV.fetch(
    "FOREST_AUTH_SECRET",
    Rails.application.credentials.forest_auth_secret,
  )

And I migrated keys from secret.yml into development credentials.