Skip to content

Conversation

jasoncwik
Copy link

When issuing list requests using the AWS module, we noticed that list objects requests were failing due to a strange URI. We saw the generated URI was

http://server/bucket?&list-type=2&prefix=foo/

but it should be

http://server/bucket?list-type=2&prefix=foo/

i.e. the query string should not start with an ampersand before the list-type parameter.

Which issue does this PR close?

Closes #434

Rationale for this change

Fixes URI query parameter building to be more standard.

What changes are included in this PR?

One change to URI building.

Are there any user-facing changes?

None.

When issuing list requests using the AWS module, we noticed that list
objects requests were failing due to a strange URI. We saw the generated
URI was

`http://server/bucket?&list-type=2&prefix=foo/`

but it should be

`http://server/bucket?list-type=2&prefix=foo/`

i.e. the query string should not start with an ampersand before the
list-type parameter.
@jasoncwik jasoncwik marked this pull request as ready for review July 10, 2025 23:30
let mut encoder = form_urlencoded::Serializer::for_suffix(&mut out, start_position);
// Build the query string, preserving any existing query parameters.
// This prevents malformed URIs like "/bucket?&list-type=2" when the URI
// already contains query parameters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to handle this case, we didn't before - we solely used the path?

Was this AI generated or something?

Choose a reason for hiding this comment

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

Not sure if it's really a bug in the library. A query string that starts with an ampersand works fine in php($_GET["var"]) and python3 urllib parse_qs. I am also unable to find any RFC or protocol specification that outlines that a query string should not/cannot begin with an ampersand.

@tustvold tustvold marked this pull request as draft July 28, 2025 13:31
@tustvold
Copy link
Contributor

Converting to draft as not waiting on review

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.

URI builder starts query strings with ampersand
3 participants