cli icon indicating copy to clipboard operation
cli copied to clipboard

apiGet sends params as ?input=<JSON> instead of named query params — all GET commands with parameters fail (400)

Open decodevM opened this issue 3 months ago • 1 comments

Problem

Any CLI command that maps to a GET endpoint with query parameters fails:

dokploy compose one --composeId <valid-id> --json
# Request failed with status code 400

This affects every "read one" / "search" style command across the API (compose one, application one, project one, mysql one, registry one, *.search, *.readLogs, etc. — anything backed by a GET with query params in openapi.json). Commands backed by POST (deploy, delete, update, create) are unaffected.

Root cause

In src/client.ts:

export async function apiGet(
	endpoint: string,
	params?: Record<string, unknown>,
) {
	const client = createClient();
	const query = params
		? `?input=${encodeURIComponent(JSON.stringify(params))}`
		: "";
	const response = await client.get(`/trpc/${endpoint}${query}`);
	return response.data?.result?.data?.json ?? response.data;
}

This wraps all params into one JSON-encoded input query string — the convention for calling tRPC procedures directly. But the REST surface this CLI actually targets (per its own openapi.json) expects each parameter as its own named query key, e.g. ?composeId=<id>, not a JSON blob under input.

Confirmed directly: the same request, same auth, sent as a plain named query param instead of through the CLI, succeeds:

curl -s -H "x-api-key: $DOKPLOY_AUTH_TOKEN" \
  "https://<host>/api/compose.one?composeId=<valid-id>"
# returns the full object correctly

Suggested fix

const response = await client.get(`/trpc/${endpoint}`, { params });

Environment

@dokploy/cli 0.29.14 (also reproduced on 0.3.0 — not version-specific).

decodevM avatar Aug 13 '26 14:08 decodevM

Ran into this too on 0.30.2 — every GET command with params 400s for me (read-logs, *.one, search, ...), POST stuff like deploy works fine.

Tried the fix suggested here and it didn't work for me, server still returns 400 with "Invalid input: expected object, received undefined" when passing named query params to /trpc/.

What did work: wrapping the params in { json: ... } before encoding:

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

Hitting the plain REST routes directly also works — GET /api/application.readLogs?applicationId=...&tail=5 returns 200 — so fixing it that way could work too if that matches openapi.json better.

R-udren avatar Aug 29 '26 15:08 R-udren