mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-31 13:03:49 +08:00
fix(api): allow canvas_type in agent create and update APIs (#15201)
### What problem does this PR solve?
Creating or updating an agent via `POST /api/v1/agents` and `PUT
/api/v1/agents/{agent_id}` did not persist `canvas_type` because the
handler `req` dict never assigned the field before
`UserCanvasService.save` / `update_by_id`.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -80,6 +80,9 @@ def test_create_agent_payload_and_error(monkeypatch):
|
||||
client.create_agent("agent-title", {"graph": {}}, description="desc")
|
||||
assert calls[-1][1] == {"title": "agent-title", "dsl": {"graph": {}}, "description": "desc"}
|
||||
|
||||
client.create_agent("agent-title", {"graph": {}}, canvas_type="Marketing")
|
||||
assert calls[-1][1] == {"title": "agent-title", "dsl": {"graph": {}}, "canvas_type": "Marketing"}
|
||||
|
||||
monkeypatch.setattr(client, "post", lambda *_args, **_kwargs: _DummyResponse({"code": 1, "message": "create boom"}))
|
||||
with pytest.raises(Exception) as exception_info:
|
||||
client.create_agent("agent-title", {"graph": {}})
|
||||
@@ -104,6 +107,7 @@ def test_update_agent_payload_matrix_and_error(monkeypatch):
|
||||
{"title": "new-title", "description": "new-description", "dsl": {"nodes": []}},
|
||||
{"title": "new-title", "description": "new-description", "dsl": {"nodes": []}},
|
||||
),
|
||||
({"canvas_type": "Agent"}, {"canvas_type": "Agent"}),
|
||||
]
|
||||
for kwargs, expected_payload in cases:
|
||||
client.update_agent("agent-1", **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user