Skip to content

Support hackney 3+ response format in generated clients - #137

Merged
onno-vos-dev merged 1 commit into
aws-beam:masterfrom
kresimir-baksa:TSK-138520-hackney-3-compat
Nov 10, 2026
Merged

onno-vos-dev merged 1 commit into
aws-beam:masterfrom
kresimir-baksa:TSK-138520-hackney-3-compat

Conversation

@kresimir-baksa

Copy link
Copy Markdown
Contributor

Support hackney 3+ response format in generated clients

Fixes #136

hackney 3.0 removed hackney:body/1 and returns the body in the response tuple, so the generated clients crash with undef on hackney 3 or later.

Changes in priv/post.erl.eex and priv/rest.erl.eex:

  • add a response_body/1 helper: a binary is returned as {ok, Body}, anything else goes through hackney:body/1, so hackney 1.x and 2.x behave as before
  • use it instead of calling hackney:body(Client) directly
  • use term() instead of the removed hackney:client() type in the generated specs
  • add -ignore_xref([{hackney, body, 1}])

How I tested:

  • generated all clients with mix run generate.exs erlang from the current aws/aws-sdk-go-v2 specs into a copy of aws-erlang
  • compiled the result on OTP 28 against hackney 1.25.0 and 4.9.1
  • called aws_sqs:send_message/2 against a local HTTP endpoint on both versions: it returns {ok, Result, _} on both (with hackney 1.25.0 the body is read through hackney:body/1, with 4.9.1 it is already a binary)
  • not run: rebar3 ct (needs the dynamodb-local and s3mock containers), the CI workflow runs it

Notes:

  • about 49 modules in aws-erlang belong to services that are no longer in the specs (for example aws_alexa_for_business). The generator does not rewrite them, so they still call hackney:body/1.
  • this PR does not bump the hackney version in aws-erlang; that is left to the maintainers.

hackney 3.0 removed hackney:body/1 and returns the body itself in the
response tuple, so generated clients crash on hackney 3 and later.

Read the body through a generated response_body/1 helper that returns a
binary as is and otherwise calls hackney:body/1, so the clients work with
hackney 1.x and 2.x as before and with hackney 3.0 and later. Replace the
hackney:client() type, which hackney 3 removed, with term().
@onno-vos-dev

Copy link
Copy Markdown
Member

I will generate new aws-erlang for you tonight (CET) and roll out a release 👍

Thank you! ❤️

@onno-vos-dev
onno-vos-dev merged commit 183338f into aws-beam:master Nov 10, 2026
3 checks passed
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.

Generated clients crash on hackney 3+ because hackney:body/1 was removed

2 participants