An agent's full message content is logged at DEBUG, against the stated position that logs carry no message bodies

Open Beginner friendly
#2,159 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start at core/switch_core/bridges/agent/api/handlers.py:489 in the message-send handler and check the request model for the correct room field name (req.room_id) alongside req.content. Then read core/switch_core/observability/logs.py to confirm no filter strips record text, since it ships to a collector as well as stderr. Done means the debug line reports agent, room and character count only, with no body, and any log-assertion test near that handler still passes.

Written by the indexing model from the issue text.

Description

What happens

core/switch_core/bridges/agent/api/handlers.py:489, in the agent message-send handler:

logger.debug("Recieved message from agent %s: %s", agent.name, req.content)

req.content is the whole body of the message the agent is sending into a room. At DEBUG, every agent message is written to the log in full, with the agent's name beside it.

Why it matters

Three things make this more than a stray debug line.

  1. It contradicts the project's own stated position. docs/design/data-retention.md:

    Application logs do not include message bodies by default. Any change that starts logging them should be treated as personal-data processing.

    That sentence is relied on when answering customers' data questions. It is true except here.

  2. There is no content redaction in the logging pipeline. core/switch_core/observability/logs.py has one filter, and its purpose is to avoid mislabelling ops lines as product events — not to strip personal data. Nothing inspects a record's text before it is emitted.

  3. The record does not stay on the box. That module ships log records to a collector in addition to stderr: "Shipping log records to the collector, alongside writing them to stderr. stderr is never replaced — this handler is additional." So a deployment running at DEBUG sends room message content to wherever its collector forwards to, which is a different set of processors from the ones the data is meant to touch.

By contrast, the project is careful about this elsewhere: product telemetry explicitly never sends prompts, room names, error messages or log content, and agent hosts redact issued tokens from logs and journals. This line is the exception.

Scope

As far as I can tell it is the only one. Grepping core/switch_core/ for logging calls carrying a message body, content or text field returns this line alone.

Suggested fix

Log the fact and the shape, not the content — the agent, the room, and a length or hash is enough to debug a delivery problem:

logger.debug(
    "Received message from agent %s for room %s (%d chars)",
    agent.name, req.room_id, len(req.content),
)

(The existing line also misspells "Recieved", if it is being touched anyway.)

If the full body is genuinely wanted for local debugging, it would be better behind an explicit opt-in that a deployment has to turn on knowingly, rather than riding on the log level.

Verified at switch-v0.32.1.

Dominant language
Python
Stars
4.5k
Forks
348
Avg merge
1d 17h
Merged PRs (30d)
287

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sandbox-quantum/switch

All issues in sandbox-quantum/switch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.