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
14 changes: 14 additions & 0 deletions test-celery-without-django/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "test-celery-without-django"
version = "0"
requires-python = ">=3.12"

dependencies = [
"celery>=5.4.0",
"ipdb>=0.13.13",
"redis>=5.2.1",
"sentry-sdk[celery]",
]

[tool.uv.sources]
sentry-sdk = { path = "../../sentry-python", editable = true }
6 changes: 0 additions & 6 deletions test-celery-without-django/requirements.txt

This file was deleted.

23 changes: 5 additions & 18 deletions test-celery-without-django/run-celery.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
#!/usr/bin/env bash

# exit on first error
set -euo pipefail

# Delete Celery beat schedule because because when switching versions
# a wrong schedule will cause strange errors
rm -f celerybeat-schedule
if ! command -v uv &> /dev/null; then
curl -LsSf https://astral.sh/uv/install.sh | sh
fi

# Delete redis database (empty the queue)
rm -f celerybeat-schedule
rm -rf dump.rdb

# create and activate virtual environment
python -m venv .venv
source .venv/bin/activate

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

uv not on PATH after install

Medium Severity

If uv is missing, the scripts install it, but the installer doesn't make uv immediately available on the PATH for the current shell session. This happens because it updates shell profiles for future sessions or places uv in ~/.local/bin, which may not be on the PATH for non-interactive runs. Consequently, the immediate uv run command fails.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 65f5f30. Configure here.


# Install (or update) requirements
pip install -r requirements.txt

# Start redis server
redis-server --daemonize yes

# Run Celery and beat in the same process
celery -A tasks.app worker \
uv run celery -A tasks.app worker \
--concurrency=1 \
--max-tasks-per-child=1

# --loglevel=DEBUG \
15 changes: 5 additions & 10 deletions test-celery-without-django/run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

# exit on first error
set -xe
if ! command -v uv &> /dev/null; then
curl -LsSf https://astral.sh/uv/install.sh | sh
fi

# create and activate virtual environment
python -m venv .venv
source .venv/bin/activate

# Install (or update) requirements
python -m pip install -r requirements.txt

python main.py
uv run python main.py
Comment on lines +4 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The script calls uv immediately after installation without updating the shell's PATH, causing a command not found error on fresh systems where uv is not pre-installed.
Severity: HIGH

Suggested Fix

After the uv installation command, source the appropriate environment file to update the PATH for the current shell session. For example, add source "$HOME/.cargo/env" or a similar command before the first uv call. This will make the uv binary available in the script's execution context.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: test-celery-without-django/run.sh#L4-L8

Potential issue: The script auto-installs `uv` using its official installer, which adds
the binary's location to shell configuration files like `.bashrc`. However, it does not
update the `PATH` for the current, non-interactive shell session. The script then
immediately attempts to execute `uv run python main.py`. On a system where `uv` was not
previously installed, this command fails. Since `set -e` is enabled, the script exits
immediately, making the installation block ineffective and preventing the setup from
completing. The same logic flaw is present in `run-celery.sh`.

Did we get this right? 👍 / 👎 to inform future reviews.

Loading