Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/mock_vws/_flask_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ COPY --chown=myuser:myuser . /app

# See https://pythonspeed.com/articles/activate-virtualenv-dockerfile/
# For why we use this method of activating the virtual environment.
ENV VIRTUAL_ENV=/app/docker_venvs/.venv
ENV UV_PROJECT_ENVIRONMENT=/app/docker_venvs/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PATH="$UV_PROJECT_ENVIRONMENT/bin:$PATH"
Copy link

Choose a reason for hiding this comment

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

Removing standard VIRTUAL_ENV breaks Python venv detection

Medium Severity

VIRTUAL_ENV is a Python ecosystem standard env var used by tools like pip, shell prompts, and other utilities to detect an active virtual environment. UV_PROJECT_ENVIRONMENT is uv-specific and not a substitute — they serve different purposes. Removing VIRTUAL_ENV means standard Python tooling inside the container won't recognize the venv. The comment on lines 12–13 referencing the pythonspeed article also becomes misleading, since that technique explicitly relies on setting VIRTUAL_ENV.

Fix in Cursor Fix in Web


WORKDIR /app
RUN python3 -m venv $VIRTUAL_ENV && \
RUN python3 -m venv $UV_PROJECT_ENVIRONMENT && \
pip install --no-cache-dir uv==0.10.4 && \
uv sync --no-cache
EXPOSE 5000
Expand Down
9 changes: 8 additions & 1 deletion tests/mock_vws/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import datetime
import io
import json
import re
import textwrap
import time
import uuid
Expand Down Expand Up @@ -72,6 +73,8 @@
""",
)

_JETTY_VERSION_RE = re.compile(pattern=r"Powered by Jetty:// [\d.]+")

_NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR = textwrap.dedent(
text="""\
<html>\r
Expand Down Expand Up @@ -252,7 +255,11 @@ def test_incorrect_no_boundary(
if resp_status_code != HTTPStatus.INTERNAL_SERVER_ERROR:
handle_server_errors(response=vws_response)

assert requests_response.text == resp_text
repl = "Powered by Jetty://"
sub = _JETTY_VERSION_RE.sub
actual = sub(repl=repl, string=requests_response.text)
expected = sub(repl=repl, string=resp_text)
assert actual == expected
assert_vwq_failure(
response=vws_response,
status_code=resp_status_code,
Expand Down