Skip to content

feat: add support for the HTTP QUERY method (RFC 10008)#896

Merged
yordis merged 2 commits into
masterfrom
query-http-method
Jul 9, 2026
Merged

feat: add support for the HTTP QUERY method (RFC 10008)#896
yordis merged 2 commits into
masterfrom
query-http-method

Conversation

@hodak

@hodak hodak commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Generate query/query! client helpers (carrying a request body, like post) and extend the Tesla.Env method type with :query.

Adapter support: hackney, gun, and mint pass QUERY through already; finch now receives the method as an uppercase string, since Finch rejects unknown method atoms (it normalizes atom methods to strings internally, so this is behavior-identical for the other methods). ibrowse crashes its connection process on unknown method atoms, so its adapter rejects QUERY upfront with {:error, :method_not_supported_by_adapter}. httpc passes through its own {:error, :invalid_method}, so QUERY starts working there automatically once OTP adds support for it.

Generate query/query! client helpers (carrying a request body, like
post) and extend the Tesla.Env method type with :query.

Adapter support: hackney, gun, and mint pass QUERY through already;
finch now receives the method as an uppercase string, since Finch
rejects unknown method atoms (it normalizes atom methods to strings
internally, so this is behavior-identical for the other methods).
ibrowse crashes its connection process on unknown method atoms, so its
adapter rejects QUERY upfront with
{:error, :method_not_supported_by_adapter}. httpc passes through its
own {:error, :invalid_method}, so QUERY starts working there
automatically once OTP adds support for it.

Document the adapter support matrix in the adapter guide, the Httpc
and Ibrowse moduledocs, and the general cheatsheet.
Copilot AI review requested due to automatic review settings July 6, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for the HTTP QUERY method (RFC 10008) across Tesla’s generated client helpers, environment typing, adapter behavior, and documentation, with adapter-specific handling where underlying clients reject unknown methods.

Changes:

  • Extend Tesla.Env.method() and Tesla.Builder’s generated helpers to include :query / query / query! (with request-body support).
  • Ensure Finch can send QUERY by passing an uppercase string method to Finch, and add a shared adapter test case for QUERY where supported.
  • Document adapter-level method support and add explicit error behavior for adapters that cannot support QUERY (ibrowse, httpc).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/tesla/builder_test.exs Verifies query/query! functions are generated and included in verb lists.
test/tesla/adapter/mint_test.exs Enables shared QUERY adapter test case for Mint.
test/tesla/adapter/hackney_test.exs Enables shared QUERY adapter test case for Hackney.
test/tesla/adapter/gun_test.exs Enables shared QUERY adapter test case for Gun.
test/tesla/adapter/finch_test.exs Enables shared QUERY adapter test case for Finch.
test/tesla/adapter/ibrowse_test.exs Adds explicit test asserting ibrowse adapter rejects QUERY.
test/tesla/adapter/httpc_test.exs Adds explicit test asserting :httpc returns :invalid_method for QUERY (version-dependent concern noted).
test/tesla_test.exs Adds a shortcut-function test for SimpleClient.query/2.
test/support/adapter_case/query.ex Introduces shared adapter test case for sending QUERY over the wire.
lib/tesla/env.ex Extends method type to include :query.
lib/tesla/builder.ex Adds query to verb generation and documents the QUERY vs :query option naming collision.
lib/tesla/adapter/finch.ex Uses shared format_method/1 to send method as uppercase string to Finch.
lib/tesla/adapter/ibrowse.ex Rejects :query upfront to prevent ibrowse connection-process crashes.
lib/tesla/adapter/httpc.ex Documents QUERY as unsupported by :httpc (wording consistency concern noted).
guides/explanations/3.adapter.md Documents per-adapter QUERY support and failure modes.
guides/cheatsheets/general.cheatmd Adds Tesla.query/2 example and notes adapter limitations (wording consistency concern noted).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/tesla/adapter/httpc.ex Outdated
Comment thread lib/tesla/adapter/ibrowse.ex Outdated
Comment thread guides/cheatsheets/general.cheatmd Outdated
Comment thread test/tesla/adapter/httpc_test.exs Outdated
Reword the httpc adapter note and the cheatsheet to make QUERY support
explicitly OTP-version dependent, match the ibrowse guard on Tesla.Env
instead of any map, and make the httpc QUERY test accept a successful
response so CI stays green on OTP versions that add QUERY support.
@yordis

yordis commented Jul 6, 2026

Copy link
Copy Markdown
Member

@hodak thank you so much! This starts to become a crazy situation with supported features 😭

Also, could you try to make CI to be green/ 🙏🏻

@hodak

hodak commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

The CI failures are unrelated to this PR. The test jobs die in the setup step - Hex crashes while Mix loads the dependency graph, before any test runs:

{:failed_to_start_child, Hex.State,
 {:undef, [{:re, :import, [{:re_exported_pattern, ...}]}, ...]}}

This is hexpm/hex#1197: Hex 2.5.0 (published June 29) embeds compiled PCRE2 regex literals in its beam files, restored at runtime via :re.import/1, which does not exist on the OTP versions in this repo's test matrix. Since CI installs the latest Hex with mix local.hex --force, every branch has been failing the same way since then - e.g. the dependabot runs from July 1 fail identically.

The issue is fixed upstream but not yet released (latest release is still v2.5.0). Until a fixed Hex ships, CI could pin the previous version in the install step:

mix local.hex 2.4.2 --force

@yordis yordis merged commit c3b7bf5 into master Jul 9, 2026
9 of 18 checks passed
@yordis yordis deleted the query-http-method branch July 9, 2026 09:21
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.

3 participants