pytest-dev / pytest-dev/pytest-flask
Regression: localhost.localdomain default breaks name resolution
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 499
- Forks
- 93
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
In version 1.2.1, the following update was made:
Fix bug in :meth:pytest_flask.fixtures.live_server where SESSION_COOKIE_DOMAIN was set to false due to original_server_name defaulting to "localhost". The new default is "localhost.localdomain".
This causes issues when we go to make requests to our Flask test server. Specifically we get errors that look like this:
WARNING urllib3.connectionpool:connectionpool.py:871 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NameResolutionError("<urllib3.connection.HTTPConnection object at 0x16dd5a4d0>: Failed to resolve 'localhost.localdomain' ([Errno 8] nodename nor servname provided, or not known)")': /graphql
When we make a request to url_for, we get back a URL that looks like http://localhost.localdomain/graphql instead of http://localhost/graphql
While I know I can add localhost.localdomain to my local /etc/hosts file, there are many docker images we're using in our CI pipelines that also do not know how to resolve this domain name.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at pytest_flask.fixtures.live_server and inspect how original_server_name, SESSION_COOKIE_DOMAIN, and url_for determine the test server hostname. Reproduce the failing request or URL generation, then verify that the resulting URL uses localhost and resolves in the affected CI environments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100