agentscope-ai / agentscope-ai/QwenPaw

fix(config): invalid single-channel payloads return HTTP 500

Offen Anfängerfreundlich
#6,910 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
35k
Forks
3.1k
Ø Merge
1 T. 13 Std.
Gemergte PRs (30 T.)
228

Beschreibung

## QwenPaw Version

`2.1.0b3`, current `main` at `e09e1a28f515e71f687f0ed5c4b04ed4f152181e`.

## Description

`PUT /api/config/channels/{channel_name}` accepts an untyped JSON object and
constructs the selected built-in channel model inside the route. If that
construction raises a Pydantic `ValidationError`, the exception is not mapped
to a client validation response, so the API returns HTTP 500.

The complete-channel endpoint already returns HTTP 422 for the same class of
invalid input. The single-channel endpoint should preserve that API contract
and must not turn user input errors into internal server errors.

**Related PR(s):** Follow-up to #6864.

**Security considerations:** None. This is error classification for invalid
configuration input; the invalid value is not persisted.

## Component(s) Affected

- [x] Core / Backend (app, agents, config, providers, utils, local_models)
- [ ] Console (frontend web UI)
- [x] Channels (DingTalk, Lark, QQ, Discord, iMessage, etc.)
- [ ] Skills
- [ ] CLI
- [ ] Documentation (website)
- [x] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy

## Environment

- **QwenPaw version:** `2.1.0b3` / `e09e1a28`
- **OS:** macOS 26.5.1
- **Install method:** source checkout with repository `.venv`
- **Python version:** 3.11.15

## Steps to Reproduce

1. Start the FastAPI config router with a valid agent workspace.
2. Send:

```http
PUT /api/config/channels/onebot
Content-Type: application/json

{"enabled": true, "ws_port": "not-a-port"}
```

3. Inspect the response and persistence call.

## Actual vs Expected

- **Actual:** HTTP 500 with `Internal Server Error`; `save_agent_config()` is
not called.
- **Expected:** HTTP 422 with validation details; `save_agent_config()` remains
uncalled.

## Logs / Screenshots

```text
status=500
body=Internal Server Error
save_called=False
```

The current regression test
`test_put_onebot_channel_rejects_invalid_value` accepts either 422 or 500 and
notes that the Pydantic error currently propagates.

## Additional Notes

Open issue/PR searches for channel config validation, HTTP 422, Pydantic
`ValidationError`, and OneBot invalid config handling found no active
implementation. The report and proposed fix were AI-assisted and personally
reproduced against the exact current `main` revision above.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the PUT /api/config/channels/{channel_name} route and the regression test test_put_onebot_channel_rejects_invalid_value. Compare its handling of Pydantic ValidationError with the complete-channel endpoint, then run the test and confirm invalid input returns HTTP 422 with validation details while save_agent_config() remains uncalled.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
fastapi, python
Bereich
api, backend, testing
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
82/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.