Skip to content

Replace HTTPoison with Finch - #66

Open
gilbertwong96 wants to merge 3 commits into
navinpeiris:masterfrom
gilbertwong96:replace-httpoison-with-finch
Open

Replace HTTPoison with Finch#66
gilbertwong96 wants to merge 3 commits into
navinpeiris:masterfrom
gilbertwong96:replace-httpoison-with-finch

Conversation

@gilbertwong96

Copy link
Copy Markdown

Swaps the HTTP client from HTTPoison to Finch, and bumps Cachex from 3.x to 4.x.

  • Replace HTTPoison.get/1 with Finch.build/2 + Finch.request/2, backed by a supervised GeoIP.Finch instance added to the app supervisor
  • Map HTTPoison.Response/HTTPoison.Error to Finch.Response and Finch exceptions (Finch.Error, Finch.TransportError, Finch.HTTPError, all of which expose :reason)
  • Update mocked tests to stub the Finch boundary (build/2 + request/3) returning %Finch.Response{status:, body:}
  • Bump cachex ~> 3.3~> 4.0; verified against the v4 migration guide that none of the breaking changes affect the three Cachex call sites in use (Cachex.Spec.expiration/1, Cachex.get/3, Cachex.put/4)
  • Bump Elixir floor to ~> 1.16 (Finch requires ~> 1.15) and align .tool-versions with Erlang 29 / Elixir 1.20

Behavior verified end-to-end against a live local HTTP server (happy path, non-200, non-JSON body, and transport errors), since the mock/meck test dep doesn't compile on OTP 29 (pre-existing — meck 0.9.2 uses deprecated catch syntax).

HTTPoison 2.x (the pinned version) depends on hackney < 4.0, which is affected by CVE-2026-47075 (HTTP request splitting) and CVE-2026-47066 (DoS). Migrating to Finch drops the hackney dependency entirely.

- Swap httpoison dep for finch ~0.19 and bump elixir floor to ~> 1.15
- Start a supervised Finch instance (GeoIP.Finch) in the app supervisor
- Replace HTTPoison.get/1 with Finch.build/2 + Finch.request/2
- Map HTTPoison.Response/Error structs to Finch.Response and Finch exceptions
- Update mocked tests to stub the Finch boundary
Verified against the v4 migration guide: none of the breaking changes
(removed :fallback/:stats/:limit/:nodes options, fetch/4 return change,
:ttl -> :expire rename, count/dump/load/set removals) touch the three
Cachex call sites in use (Cachex.Spec.expiration/1, Cachex.get/3, Cachex.put/4).
Cachex.Spec.expiration/1 is now a Record macro but the require + fully-qualified
call form still resolves. Full stack verified via live HTTP + cache round-trip.
Raise elixir floor to ~> 1.16 and align .tool-versions with the local
toolchain used for the Finch/Cachex migration.
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