Skip to content

FormRequest.formdata with GET method duplicates same key in query string #2919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
skynetbinary opened this issue Sep 10, 2017 · 5 comments
Closed

Comments

@skynetbinary
Copy link

>>> from scrapy import FormRequest
>>> FormRequest('http://example.com/?id=9', method='GET', formdata={'id': '8'}).url
'http://example.com/?id=9&id=8'

Notice how id is being duplicated in query string. It must replace the value if same key is found. I believe this can be handled in form.py#L36.

@kmike
Copy link
Member

kmike commented Dec 12, 2017

Yes, this looks like a bug.

@jslay88
Copy link

jslay88 commented Dec 14, 2017

Hopefully that works for you. First time making a PR, so please excuse any errors.

I would like some advice on how to build a good unit test for this, as I will admit, my testing experience is not great.

@keremgocen
Copy link

anyone working on this?

@Gallaecio
Copy link
Member

Gallaecio commented Oct 11, 2020

I’m not sure this should be considered a bug. Specially after giving some thought to #4730.

Maybe we should simply raise a ValueError exception in this scenario, where formdata needs to be defined as a URL query string and the specified URL already has a query string.

wRAR added a commit that referenced this issue Jun 15, 2021
[MRG+1] Issue #2919: Fix FormRequest.formdata with GET method duplicates same key in query string
@Gallaecio
Copy link
Member

Fixed by #3579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants