feat(query): support API-specific query serialization#843
Conversation
yordis
commented
Apr 21, 2026
- keeps query parameters as structured data so middleware and logging can still reason about them
- lets callers use API-specific serializers without forcing Tesla to depend on Plug
- closes Query parameters do not support nested maps #538 by covering nested maps and caller-provided query encoding in the request path
PR SummaryMedium Risk Overview Introduces custom query serialization via a Updates No new environment variables were introduced in this diff. Reviewed by Cursor Bugbot for commit c4ca37e. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Adds support for keeping query parameters as structured data (including nested maps) while allowing API-specific/custom query serialization (e.g., Plug’s encoder) without adding a Plug dependency.
Changes:
- Extend
Tesla.Envquery param types to support nested maps in addition to lists. - Add support for passing a custom
query_encodingfunction, and add nested-map expansion during query encoding. - Add test coverage for nested-map query encoding and custom query encoder integration (including logger output).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
lib/tesla.ex |
Extends query encoding strategy to accept a function and adds nested-map flattening during encoding. |
lib/tesla/env.ex |
Updates typespecs to allow query params as nested maps. |
test/tesla_test.exs |
Adds tests for nested-map query encoding and custom encoder usage via build_url/3 and Tesla.build_url/1. |
test/tesla/middleware/logger_test.exs |
Adds tests ensuring logger formatting/debug output handles nested-map queries and custom encoders. |
Comments suppressed due to low confidence (1)
lib/tesla.ex:391
- The
build_url/3docs still describequeryas “a list of key-value pairs”, but this PR now supports maps (including nested maps) as well. Updating that bullet (and/or examples) to explicitly mention map support would keep the docs consistent with the new types and behavior.
- `url` - the base URL to which the query params will be appended.
- `query` - a list of key-value pairs to be encoded as query params.
- `encoding` - the encoding strategy to use. Defaults to `:www_form`
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
lib/tesla.ex:391
- The
build_url/3docs still state thatqueryis “a list of key-value pairs”, but the implementation/spec now accepts maps (including nested maps). Updating this bullet (and any surrounding wording) would keep the docs aligned with the new behavior.
- `url` - the base URL to which the query params will be appended.
- `query` - a list of key-value pairs to be encoded as query params.
- `encoding` - the encoding strategy to use. Defaults to `:www_form`
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 334a670. Configure here.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
lib/tesla.ex:391
- In the
build_url/3docs, thequeryparameter is still described as “a list of key-value pairs”, but the implementation and tests now support passing a map (including nested maps). Updating this bullet to mention maps will keep the public docs consistent with the new behavior.
- `url` - the base URL to which the query params will be appended.
- `query` - a list of key-value pairs to be encoded as query params.
- `encoding` - the encoding strategy to use. Defaults to `:www_form`
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
lib/tesla.ex:391
- The
build_url/3docs still sayqueryis “a list of key-value pairs”, but the function now accepts maps (including nested maps) as well. Updating this bullet to mention maps will keep the public docs consistent with the new behavior and examples.
- `url` - the base URL to which the query params will be appended.
- `query` - a list of key-value pairs to be encoded as query params.
- `encoding` - the encoding strategy to use. Defaults to `:www_form`
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
072c5db to
aad57f6
Compare
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
