Skip to content

fix: skip Set-Cookie headers without a cookie in hackney:cookies/1 - #994

Open
wleeaf wants to merge 1 commit into
benoitc:masterfrom
wleeaf:cookies-empty-set-cookie
Open

wleeaf wants to merge 1 commit into
benoitc:masterfrom
wleeaf:cookies-empty-set-cookie

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 26, 2026

Copy link
Copy Markdown

What

hackney:cookies/1 crashes with {case_clause, []} when a Set-Cookie header holds no cookie:

1> hackney:cookies([{<<"Set-Cookie">>, <<>>}, {<<"Set-Cookie">>, <<"k1=v1">>}]).
** exception error: no case clause matching []

Why

hackney_cookie:parse_cookie/1 returns [] for an empty value, for a value made only of separators (" ; "), and for a single $-prefixed name ($Version=1), which it skips. cookies/1 only handles {error, _} and a non-empty list, so one such header makes the whole call fail, and the other cookies in the response are lost with it.

These headers are now skipped, like the ones parse_cookie/1 rejects.

How to test

hackney_cookie_tests:cookies_test_/0 passes an empty header, a header with only separators, a $Version=1 header and a normal cookie. It fails with the case_clause error without the change and returns the normal cookie with it. rebar3 eunit --module=hackney_cookie_tests passes (27 tests), and rebar3 xref and rebar3 dialyzer are clean (OTP 28).

hackney:cookies/1 crashed with a case_clause error when a Set-Cookie
value parsed to no cookie at all: an empty value, one holding only
separators, or a single $-prefixed name. Such headers are now skipped.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T10:31:37.595426Z
We couldn’t complete this review. Comment @codex review to try again.
455f1e6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Successfully merging this pull request may close these issues.

1 participant