From 56aebc882c573b9783f6c74cf816677c261c14ff Mon Sep 17 00:00:00 2001 From: arc53-machine <232052973+arc53-machine@users.noreply.github.com> Date: Mon, 28 Sep 2026 14:55:43 +0100 Subject: [PATCH] Cover the chunks fallbacks on agent update and YAML import A blank chunks on update and an unparsable one on import both fall back to the default. --- tests/api/test_agent_portability.py | 7 +++++++ tests/api/user/agents/test_routes_happy.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/api/test_agent_portability.py b/tests/api/test_agent_portability.py index c983a225..a960dd60 100644 --- a/tests/api/test_agent_portability.py +++ b/tests/api/test_agent_portability.py @@ -183,6 +183,13 @@ def test_import_without_chunks_uses_the_default(pg_conn): assert agent["chunks"] == 6 +def test_import_with_invalid_chunks_uses_the_default(pg_conn): + user = "u_invalid_chunks" + result = apply_import(pg_conn, user, _doc(name="Odd Bot", _slug="odd-bot", chunks="lots")) + agent = AgentsRepository(pg_conn).get(result["agent_id"], user) + assert agent["chunks"] == 6 + + def test_import_keeps_explicit_chunks(pg_conn): user = "u_explicit_chunks" result = apply_import(pg_conn, user, _doc(name="Off Bot", _slug="off-bot", chunks=0)) diff --git a/tests/api/user/agents/test_routes_happy.py b/tests/api/user/agents/test_routes_happy.py index 70ee7d89..a9fe198d 100644 --- a/tests/api/user/agents/test_routes_happy.py +++ b/tests/api/user/agents/test_routes_happy.py @@ -648,6 +648,23 @@ class TestUpdateAgent: field in msg and user in msg for msg in warnings ), f"no WARN naming field={field!r} and user={user!r}; got {warnings!r}" + def test_blank_chunks_resets_to_the_default(self, app, pg_conn): + from docsgpt.api.user.agents.routes import UpdateAgent + from docsgpt.storage.db.repositories.agents import AgentsRepository + + user = "u-upd-blank-chunks" + agent = _seed_agent(pg_conn, user=user) + with _patch_db(pg_conn), app.test_request_context( + f"/api/update_agent/{agent['id']}", + method="PUT", + json={"name": "n", "description": "d", "status": "draft", "chunks": ""}, + ): + from flask import request + request.decoded_token = {"sub": user} + response = UpdateAgent().put(str(agent["id"])) + assert response.status_code == 200 + assert AgentsRepository(pg_conn).get(str(agent["id"]), user)["chunks"] == 6 + def test_invalid_chunks_returns_400(self, app, pg_conn): from docsgpt.api.user.agents.routes import UpdateAgent