Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nitrogen over Yaws set cookie throws exception #134

Open
SserwangaV opened this issue Mar 26, 2023 · 5 comments
Open

Nitrogen over Yaws set cookie throws exception #134

SserwangaV opened this issue Mar 26, 2023 · 5 comments

Comments

@SserwangaV
Copy link

I've installed Nitrogen over Yaws (Nitrogen 2.4.0, Yaws 2.0.8, ERTS 13.2 - R25).

When I try http://0.0.0.0:8000/ I get Internal server error. When I check in the console I get this error.

{error,first_request,
    {url,"b_server/"},
    {throw,
        {badarg,same_site},
        [{yaws_api,cookie_option,2,[{file,"src/yaws_api.erl"},{line,725}]},
         {yaws_api,'-set_cookie/3-fun-0-',2,
             [{file,"src/yaws_api.erl"},{line,734}]},
         {lists,foldl,3,[{file,"lists.erl"},{line,1350}]},
         {yaws_api,set_cookie,3,[{file,"src/yaws_api.erl"},{line,733}]},
         {yaws_simple_bridge,'-assemble_headers/1-lc$^0/1-1-',1,
             [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
              {line,215}]},
         {yaws_simple_bridge,assemble_headers,1,
             [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
              {line,215}]},
         {yaws_simple_bridge,build_response,2,
             [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
              {line,161}]},
         {wf_core,run,0,[{file,"src/wf_core.erl"},{line,23}]}]}}

@choptastic
Copy link
Member

choptastic commented Mar 26, 2023 via email

@lgmfred
Copy link

lgmfred commented Aug 17, 2023

I'm having the same issue but pulling the latest simple_bridge doesn't seem to be working.

By default, the rebar.config files in both the project root directory and nitrogen_core repo pull the latest version ({branch, master}) but the bug still persists. As a temporary fix, I had to modify ./lib/nitrogen_core/rebar.config to use the tag v2.1.0 of simple_bridge.

I'm also running Nitrogen 2.4.0 over Yaws. One on OTP 24 [erts-12.3.2.13] and another on OTP 25 [erts-13.2.2].

@choptastic
Copy link
Member

Hmm, not sure how that should be the case. If your version of simple_bridge is pulled and compiled from the latest, it should be converting that SameSite variable to a binary.

What version/commit of nitrogen_core, yaws, and simple_bridge are triggering this? (and can you post the full error)?

@lgmfred
Copy link

lgmfred commented Aug 19, 2023

It turns out support for SameSite cookie was added in Yaws 2.1.0, not the default Yaws 2.0.8. I just made the app to pull Yaws-2.1.0 and was back in business.

The app was using the latest commit on the master branch of nitrogen_core@d00926a,
Yaws 2.0.8 (which is the dafault one pulled), and also the latest commit on the master branch of simple_bridge@7137f6a.

This was the error:

=INFO REPORT==== 19-Aug-2023::09:41:43.100499 ===
{error,first_request,
    {url,"localhost:8000/"},
    {throw,
        {badarg,same_site},
        [{yaws_api,cookie_option,2,[{file,"src/yaws_api.erl"},{line,725}]},
         {yaws_api,'-set_cookie/3-fun-0-',2,
             [{file,"src/yaws_api.erl"},{line,734}]},
         {lists,foldl,3,[{file,"lists.erl"},{line,1350}]},
         {yaws_api,set_cookie,3,[{file,"src/yaws_api.erl"},{line,733}]},
         {yaws_simple_bridge,'-assemble_headers/1-lc$^0/1-1-',1,
             [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
              {line,215}]},
         {yaws_simple_bridge,assemble_headers,1,
             [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
              {line,215}]},
         {yaws_simple_bridge,build_response,2,
             [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
              {line,161}]},
         {wf_core,run,0,[{file,"src/wf_core.erl"},{line,23}]}]}}

=INFO REPORT==== 19-Aug-2023::09:41:43.101523 ===
Crash Handler Crashed:
{throw,{badarg,same_site},
       [{yaws_api,cookie_option,2,[{file,"src/yaws_api.erl"},{line,725}]},
        {yaws_api,'-set_cookie/3-fun-0-',2,
                  [{file,"src/yaws_api.erl"},{line,734}]},
        {lists,foldl,3,[{file,"lists.erl"},{line,1350}]},
        {yaws_api,set_cookie,3,[{file,"src/yaws_api.erl"},{line,733}]},
        {yaws_simple_bridge,'-assemble_headers/1-lc$^0/1-1-',1,
                            [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
                             {line,215}]},
        {yaws_simple_bridge,assemble_headers,1,
                            [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
                             {line,215}]},
        {yaws_simple_bridge,build_response,2,
                            [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
                             {line,161}]},
        {wf_core,run_crash,4,[{file,"src/wf_core.erl"},{line,46}]}]}

Original Crash:
{throw,{badarg,same_site},
       [{yaws_api,cookie_option,2,[{file,"src/yaws_api.erl"},{line,725}]},
        {yaws_api,'-set_cookie/3-fun-0-',2,
                  [{file,"src/yaws_api.erl"},{line,734}]},
        {lists,foldl,3,[{file,"lists.erl"},{line,1350}]},
        {yaws_api,set_cookie,3,[{file,"src/yaws_api.erl"},{line,733}]},
        {yaws_simple_bridge,'-assemble_headers/1-lc$^0/1-1-',1,
                            [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
                             {line,215}]},
        {yaws_simple_bridge,assemble_headers,1,
                            [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
                             {line,215}]},
        {yaws_simple_bridge,build_response,2,
                            [{file,"src/yaws_bridge_modules/yaws_simple_bridge.erl"},
                             {line,161}]},
        {wf_core,run,0,[{file,"src/wf_core.erl"},{line,23}]}]}

@choptastic
Copy link
Member

choptastic commented Aug 19, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants