GET (query) requests don't wrap input in {json: ...}, breaking every parameterized read against tRPC servers using the superjson transformer

Aperta Adatta ai principianti
#46 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
86/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api, cli

Direzione di ricerca

Inizia in dist/client.js confrontando apiGet con la costruzione esistente della richiesta apiPost, quindi esegui l’applicazione dokploy segnalata con un solo comando e una query parametrizzata. Il lavoro è completato quando le richieste GET parametrizzate hanno esito positivo sui server tRPC usando superjson, mentre le query senza argomenti continuano a funzionare.

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

Descrizione

Bug

apiPost in dist/client.js correctly wraps mutation payloads as { json: data } before sending, matching tRPC's superjson transformer convention:

export async function apiPost(endpoint, data) {
    const client = createClient();
    const response = await client.post(`/trpc/${endpoint}`, data ? { json: data } : undefined);
    ...
}

apiGet does not — it sends the raw params object as the query string, unwrapped:

export async function apiGet(endpoint, params) {
    const client = createClient();
    const query = params
        ? `?input=${encodeURIComponent(JSON.stringify(params))}`
        : "";
    ...
}

Against a Dokploy server using the superjson transformer, any query procedure that requires input parameters fails with a 400:

{
  "error": {
    "json": {
      "message": "[\n  {\n    \"expected\": \"object\",\n    \"code\": \"invalid_type\",\n    \"path\": [],\n    \"message\": \"Invalid input: expected object, received undefined\"\n  }\n]",
      "code": -32600,
      "data": { "code": "BAD_REQUEST", "httpStatus": 400, "path": "application.one", ... }
    }
  }
}

Repro

dokploy application one --applicationId <id>
# Request failed with status code 400

No-argument queries (e.g. project all) work fine, since an empty/undefined input happens to satisfy those procedures' schemas either way — which is why this doesn't show up immediately.

Expected

apiGet should wrap params the same way apiPost wraps data:

const query = params
    ? `?input=${encodeURIComponent(JSON.stringify({ json: params }))}`
    : "";

Environment

  • @dokploy/cli 0.29.4 (reports dokploy --version → 0.3.0)
  • Dokploy server v0.29.11
  • Affects any query command that takes parameters: application one, deployment all, mounts list-by-service-id, log reads, etc.
Lingua principale
TypeScript
Stelle
152
Fork
46
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

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 Dokploy/cli

Tutte le issue di Dokploy/cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.