Accept integration_id for api_call
All checks were successful
Container Image / build-and-push (push) Successful in 29s

This commit is contained in:
2026-07-08 11:14:53 +02:00
parent 3705a4817e
commit 2e0e1804de
3 changed files with 48 additions and 1 deletions

View File

@@ -621,6 +621,7 @@ FUNCTION_TOOL_SCHEMAS = [
"type": "object",
"properties": {
"integration": {"type": "string", "description": "Integration name or ID (e.g. 'Miniflux', 'Gitea')"},
"integration_id": {"type": "string", "description": "Integration ID alias. Prefer 'integration' when possible; accepted for compatibility with context-provided IDs."},
"method": {"type": "string", "enum": ["GET", "POST", "PUT", "PATCH", "DELETE"], "description": "HTTP method"},
"path": {"type": "string", "description": "API endpoint path (e.g. '/v1/entries?status=unread&limit=20')"},
"body": {"type": "object", "description": "JSON request body (for POST/PUT/PATCH)"}

View File

@@ -483,7 +483,13 @@ async def do_api_call(content: str) -> Dict:
except json.JSONDecodeError:
pass
integration_name = args.get("integration", "")
integration_name = (
args.get("integration")
or args.get("integration_id")
or args.get("integrationId")
or args.get("id")
or ""
)
integrations = load_integrations()
intg = next((i for i in integrations if i["id"] == integration_name
or i["name"].lower() == integration_name.lower()), None)

View File

@@ -0,0 +1,40 @@
import json
from unittest.mock import AsyncMock, patch
import pytest
@pytest.mark.asyncio
async def test_api_call_accepts_integration_id_alias():
from src.tools import system
integrations = [
{
"id": "f9909f22dc17",
"name": "Gitea",
"enabled": True,
"base_url": "https://git.example.test",
}
]
with (
patch("src.integrations.load_integrations", return_value=integrations),
patch("src.integrations.execute_api_call", new_callable=AsyncMock) as execute,
):
execute.return_value = {"output": "ok", "exit_code": 0}
result = await system.do_api_call(json.dumps({
"integration_id": "f9909f22dc17",
"method": "GET",
"path": "/api/v1/user/repos",
}))
assert result == {"output": "ok", "exit_code": 0}
execute.assert_awaited_once_with(
"f9909f22dc17",
"GET",
"/api/v1/user/repos",
params=None,
body=None,
extra_headers=None,
)