agentscope-ai / agentscope-ai/QwenPaw

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

Aperta Adatta ai principianti
#6,910 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
35k
Fork
3.1k
Merge medio
1g 13h
PR unite (30g)
228

Descrizione

## 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
fastapi, python
Ambito
api, backend, testing
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
82/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.