Backtest read endpoints fail Pydantic validation on "created" datetime field

Aperta
#57 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
api, backend

Direzione di ricerca

Inspect the Pydantic response models used by read_backtest, list_backtests, read_backtest_chart, and read_backtest_orders, then capture or examine a list_backtests response to confirm the created value's format. Align the affected models with the API response and add a regression test using a recorded response.

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

Descrizione

Summary

The four backtest read tools (read_backtest, list_backtests, read_backtest_chart, read_backtest_orders) fail Pydantic validation on the created datetime field. The QC API returns a datetime value whose format the current Pydantic model rejects, so the wrapper throws before the response is returned to the MCP client.

This is the same class of schema drift already tracked in #50 (parameterSet), #51/#52/#54 (liveForm booleans), #56 (status enum), #40 (securityType enum) — but isolated to the created field on the backtest read path.

Impact

All four read endpoints on the backtest path are unusable from MCP clients (Claude Desktop / Claude Code / Cursor), even though the underlying QC API call succeeds and the project has 19 backtests. Write endpoints (upload_file, create_compile, create_backtest) are unaffected.

Reported by

QuantConnect support ticket — customer's MCP client (Claude) diagnosed the issue and explicitly identified the created field as the rejection point. The customer's words:

The QC API IS returning data — the error message shows 19 backtests exist in the project — but the Pydantic schema validator in the MCP client rejects the created datetime field format from QC's response, so the wrapper throws before passing anything back to me. This affects all four read endpoints (read_backtest, list_backtests, read_backtest_chart, read_backtest_orders).

Write endpoints work fine (upload, compile, create_backtest); only the read path is broken.

Proposed fix

One-liner in the MCP client's Pydantic model — either:

  1. Change created: datetime to created: Optional[datetime] on the affected response models, or
  2. Add a field_validator / BeforeValidator that tolerates the QC API's datetime format (likely a non-RFC3339 representation — exact format to be confirmed from a captured response).

A quick fix would be to relax the type on the affected models; the more durable fix is to align the Pydantic model with the actual datetime shape the QC Platform API returns and add a regression test that feeds a recorded list_backtests response through the model.

Open questions

  • Exact format of the created value the API is returning (need a captured response — the customer did not include the raw error string, only the diagnosis).
  • Whether the same field on read_project / list_projects is affected (those returned other Pydantic errors per #51/#54, so the created rejection may have been masked).

Intercom

Reported in conversation 215474584084779.

Lingua principale
Nessun dato sulla lingua
Stelle
80
Fork
32
Merge medio
1m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di QuantConnect/mcp-server

Tutte le issue di QuantConnect/mcp-server

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.