analytics icon indicating copy to clipboard operation
analytics copied to clipboard

cookie named "_plausible_key" exceeds maximum size of 4096 bytes

Open gillbates opened this issue 1 year ago • 6 comments

Past Issues Searched

  • [X] I have searched open and closed issues to make sure that the bug has not yet been reported

Issue is a Bug Report

  • [X] This is a bug report and not a feature request, nor asking for self-hosted support

Using official Plausible Cloud hosting or self-hosting?

Self-hosting

Describe the bug

version: plausible/analytics:v2.0

it always shows following error when I try to add a new site.

Server: 127.0.0.1:8000 (http)
Request: POST /sites
** (exit) an exception was raised:
    ** (Plug.Conn.CookieOverflowError) cookie named "_plausible_key" exceeds maximum size of 4096 bytes
        (plug 1.14.2) lib/plug/conn.ex:1857: Plug.Conn.verify_cookie!/2
        (plug 1.14.2) lib/plug/conn.ex:1850: anonymous fn/2 in Plug.Conn.merge_headers/2
        (stdlib 4.2) maps.erl:411: :maps.fold_1/3
        (plug 1.14.2) lib/plug/conn.ex:1842: Plug.Conn.run_before_send/2
        (plug 1.14.2) lib/plug/conn.ex:443: Plug.Conn.send_resp/1
        (plausible 0.0.1) lib/plausible_web/controllers/site_controller.ex:1: PlausibleWeb.SiteController.action/2
        (plausible 0.0.1) lib/plausible_web/controllers/site_controller.ex:1: PlausibleWeb.SiteController.phoenix_controller_pipeline/2
        (phoenix 1.7.2) lib/phoenix/router.ex:430: Phoenix.Router.__call__/5
03:33:57.914 [error] #PID<0.29009.1316> running PlausibleWeb.Endpoint (connection #PID<0.27803.1316>, stream id 20) terminated

but the site is listed after I refresh the page, any ideas why?

Expected behavior

we could add site ...

Screenshots

CleanShot 2024-02-07 at 11 38 18@2x

Environment

- OS:
- Browser:
- Browser Version:

gillbates avatar Feb 07 '24 03:02 gillbates

👋 @gillbates

Can you please show the contents of the cookie? You can decode it using your local Elixir's iex or bin/plausible remote

$ cd hosting
$ docker compose exec plausible bin/plausible remote
# your cookie would go here, this one is from https://plausible.io/login
iex> cookie = "SFMyNTY.g3QAAAABbQAAAAtfY3NyZl90b2tlbm0AAAAYdVZNNkNFVDhHQXBqcjdKUHNPWWJmZi1M.UQCIJm6UNxaBMfzZecxTtOo9YXvVIXDyWUPHfeNARUg"
iex> [_, data, _] = String.split(cookie, ".")
iex> data |> Base.decode64!(padding: false) |> :erlang.binary_to_term
%{"_csrf_token" => "uVM6CET8GApjr7JPsOYbff-L"}

ruslandoga avatar Feb 07 '24 14:02 ruslandoga

data |> Base.decode64!() |> :erlang.binary_to_term

it shows

{
  "aabbcc14.xyz_offer_email_report" => true,
  "aabbcc21.xyz_offer_email_report" => true,
  "aabbcc58.xyz_offer_email_report" => true,
  "aabbcc19.xyz_offer_email_report" => true,
  "aabbcc05.xyz_offer_email_report" => true,
  "aabbcc56.xyz_offer_email_report" => true,
  "aabbcc09.xyz_offer_email_report" => true,
  "login_dest" => nil,
  "aabbcc57.xyz_offer_email_report" => true,
  "aabbcc.fun_offer_email_report" => true,
  "aabbcc20.xyz_offer_email_report" => true,
  "aabbcc.xyz_offer_email_report" => true,
  "aabbcc27.xyz_offer_email_report" => true,
  "aabbcc28.xyz_offer_email_report" => true,
  "aabbcc30.xyz_offer_email_report" => true,
  "aabbcc53.xyz_offer_email_report" => true,
  "aabbcc39.xyz_offer_email_report" => true,
  "aabbcc38.xyz_offer_email_report" => true,
  "aabbcc50.xyz_offer_email_report" => true,
  "aabbcc02.xyz_offer_email_report" => true,
  "last_seen" => 1707317434,
  "aabbcc15.xyz_offer_email_report" => true,
  "aabbcc04.xyz_offer_email_report" => true,
  "aabbcc24.xyz_offer_email_report" => true,
  "aabbcc51.xyz_offer_email_report" => true,
  "aabbcc11.xyz_offer_email_report" => true,
  "xxx.life_offer_email_report" => true,
  "aabbcc34.xyz_offer_email_report" => true,
  "aabbcc41.xyz_offer_email_report" => true,
  "aabbcc22.xyz_offer_email_report" => true,
  "aabbcc32.xyz_offer_email_report" => true,
  "aabbcc45.xyz_offer_email_report" => true,
  "aabbcc25.xyz_offer_email_report" => true,
  "aabbcc46.xyz_offer_email_report" => true,
  "aabbcc16.xyz_offer_email_report" => true,
  "aabbcc01.xyz_offer_email_report" => true,
  "aabbcc37.xyz_offer_email_report" => true,
  "session_timeout_at" => 1708527034,
  "aabbcc33.xyz_offer_email_report" => true,
  "xxx.xyz_offer_email_report" => true,
  "aabbcc47.xyz_offer_email_report" => true,
  "xxx.fun_offer_email_report" => true,
  "aabbcc10.xyz_offer_email_report" => true,
  "aabbcc23.xyz_offer_email_report" => true,
  "aabbcc07.xyz_offer_email_report" => true,
  "aabbcc08.xyz_offer_email_report" => true,
  "aabbcc48.xyz_offer_email_report" => true,
  "aabbcc49.xyz_offer_email_report" => true,
  "aabbcc35.xyz_offer_email_report" => true,
  "aabbcc31.xyz_offer_email_report" => true,
  ...
}

gillbates avatar Feb 07 '24 14:02 gillbates

Could you please provide more context on your setup, do you have all these aabbcc**.xyz websites in your account?

ruslandoga avatar Feb 07 '24 15:02 ruslandoga

The short term fix would be to log out or delete the _plausible_key cookie and then log back in.

ruslandoga avatar Feb 07 '24 15:02 ruslandoga

Could you please provide more context on your setup, do you have all these websites in your account?

Yes.

1, I just use docker compose up to up plausible 2.0

CleanShot 2024-02-07 at 23 24 27@2x

2, I start to add sites in web page and everything works as expected. 3, This bug appears today after I added another site. I guess its caused by site count exceeds certain threshold?

gillbates avatar Feb 07 '24 15:02 gillbates

The short term fix would be to log out or delete the _plausible_key cookie and then log back in.

ok, confirmed working. thx @ruslandoga expected a fix in future and maybe a search bar in case we have many domains :)

gillbates avatar Feb 07 '24 16:02 gillbates

Done via #3892

aerosol avatar Mar 26 '24 09:03 aerosol