Skip to content

Python: [Bug]: DevUI conversation metadata accepts non-map values and then the conversation list fails #9860

Open

Description

Observed Behavior

The DevUI conversation create and update routes accept any JSON value as metadata and store it verbatim. After one such write, GET /v1/conversations returns 500 and keeps failing for every caller until the server restarts, while single conversation reads keep working, which makes the failure look random.

{"detail": "Failed to list conversations: 'NoneType' object has no attribute 'copy'"}

Expected Behavior

Metadata follows the Conversations API contract of a map with string keys and string values, so a write with any other shape is rejected with 400 at the boundary, and one bad write can never take down the list endpoint for everyone.

Steps to Reproduce

  1. Start a developer mode server (auth disabled is enough).
  2. POST /v1/conversations with body {"metadata": "oops-not-a-dict"}.
  3. POST /v1/conversations/{id} with body {"metadata": null}.
  4. GET /v1/conversations.

Minimal Reproduction

from fastapi.testclient import TestClient
from agent_framework_devui._server import DevServer

client = TestClient(DevServer(mode="developer", auth_enabled=False).create_app(), base_url="http://127.0.0.1")
created = client.post("/v1/conversations", json={"metadata": "oops-not-a-dict"})
assert created.status_code == 200          # string stored verbatim
client.post(f"/v1/conversations/{created.json()['id']}", json={"metadata": None})
listing = client.get("/v1/conversations")
assert listing.status_code == 500          # list crashes copying stored None

Error Messages and Stack Traces

Error listing conversations: 'NoneType' object has no attribute 'copy'

The crash is in list_conversations_by_metadata (_conversations.py): conv_data.get("metadata", {}).copy() returns the stored non-dict value, and .copy() raises.

Package Versions

agent-framework-devui: 1.0.0b261022 (main @ 4d28d0a)

Python Version

Python 3.14.8

Operating System

macOS

Regression

No

Additional Context

Both write sites (_server.py create and update routes) pass request_data.get("metadata") straight into the store. Validating at the boundary (map of string keys to string values, explicit null treated as an empty map) keeps the store safe for every reader. Fix ready once the team agrees with the direction.

Acknowledgements

  • I searched existing issues and did not find a duplicate.
  • I personally verified this behavior and the reproduction details are authentic.
  • I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.

Activity

  1. eavanvalkenburg commented on Oct 30, 2026

    @eavanvalkenburg
    Member

    please use the defined issue templates and wait for the team to review before opening a PR Manohar Paturi (@ManoharPaturi)

  2. changed the title [-]DevUI: unvalidated conversation metadata breaks the conversation list endpoint[/-] [+]Python: [Bug]: DevUI conversation metadata accepts non-map values and then the conversation list fails[/+] on Oct 31, 2026
  3. ZedingZhang commented on Nov 10, 2026

    @ZedingZhang
    Contributor

    Hi, bro Eduard van Valkenburg (@eavanvalkenburg) , I'd like to take this on. I'll add metadata validation and regression tests to prevent the conversation list from failing.

  4. ManoharPaturi commented on Nov 10, 2026

    @ManoharPaturi
    ContributorAuthor
  5. ManoharPaturi commented on Nov 10, 2026

    @ManoharPaturi
    ContributorAuthor

    Thanks for the ready for implementation label. Here is the plan I intend to follow, Eduard van Valkenburg (@eavanvalkenburg), and I will hold off reopening the PR until you confirm the shape.

    1. Validate at the two write boundaries only. The create and update routes in _server.py both take request_data and currently pass request_data.get("metadata") straight into the store. Each will run the value through one shared helper that accepts a map whose keys and values are all strings, treats an explicit null or a missing key as an empty map, and answers 400 with a clear detail for every other shape. The store itself stays untouched, so internal callers that always pass well formed maps are unaffected.

    2. No defensive change in the read path. Once the write boundary holds the contract, list_conversations_by_metadata can keep its current copy semantics, and I would rather not broaden that loop to tolerate poisoned entries the boundary now prevents.

    3. The earlier PR Python: validate conversation metadata at the DevUI routes #9861 (closed in the earlier sweep) already carried this exact change with route level tests for the four shapes: string metadata rejected with 400, a map with a non string value rejected, explicit null accepted as an empty map, and a valid map round tripping with the list endpoint staying healthy after the poisoned writes. I will rebase that branch against current main, re run the devui suite, and reopen as a fresh PR referencing this issue.

    One question before I start: should the 400 detail name the offending shape (for example "metadata must be a map of string keys to string values"), or do you prefer the shorter fixed message? Either is one line in the helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ready-for-implementationMaintainers agree the problem and direction are ready for implementation.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions