google / google/artemis

Stop endpoint treats string "false" as a request to stop all tasks

Open
#36 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.9k
Forks
516
Avg merge
22m
Merged PRs (30d)
5

Description

## Problem

`POST /api/stop` manually coerces the JSON body's `all` field with `bool(body["all"])`. In Python, every non-empty string is truthy, so a client sending `{"all":"false","session_id":"session-1"}` invokes `stop_tasks(clear_all=True, ...)`.

This can terminate every active task even though the caller explicitly supplied `false` and targeted one session.

## Reproduction

1. Send `POST /api/stop` with JSON body `{"all":"false","session_id":"session-1"}`.
2. Observe that `TaskQueueService.stop_tasks` receives `clear_all=True`.

The same issue affects other non-empty false-like values such as `"0"`, `"no"`, and `"off"`.

## Expected behavior

Recognized false-like values must not enable global cancellation. Unrecognized values should be rejected before any stop operation runs. Query-string `all=true` should retain precedence when explicitly supplied.

## Proposed fix

Normalize boolean body values explicitly and add router-level regression tests for false-like, true-like, and invalid values.

Contributor guide

Open the contributing guide

Research direction

Start at the router handling POST /api/stop and trace how the JSON body's all field reaches TaskQueueService.stop_tasks. Add router-level regression tests for false-like, true-like, and invalid values, while confirming query-string all=true retains precedence and invalid input triggers no stop operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.