cli icon indicating copy to clipboard operation
cli copied to clipboard

Getting "Request failed with status code 400" on every project or app request

Open yagee opened this issue 7 months ago • 6 comments

Hi all, thanks for great app!

I am succesfully auth to my panel, after that I call dokploy project all and recieve all my projects

Image

After that I call dokploy project one --projectId IawXPym-JdmnSI0_g82Wa

And I have same error every time (I tried multiple projects and applications)

Image

dokploy --version 0.3.0

yagee avatar Apr 22 '26 19:04 yagee

same

marijnbent avatar Apr 23 '26 06:04 marijnbent

Same here, 400 on every project/app request. Looks like the CLI calls /trpc/ endpoints but the server only responds on /api/ REST endpoints. Probably a mismatch between the shipped dist and the server version.

Glowvan avatar Apr 23 '26 16:04 Glowvan

Confirming this is still broken in @dokploy/[email protected] against a fresh Dokploy v0.29.4 server.

Root cause

apiGet in src/client.ts sends raw input, but the tRPC v10 backend expects the transformer wrapper {json: ...}. Compare with apiPost in the same file:

// apiPost — wraps correctly
const response = await client.post(
    `/trpc/${endpoint}`,
    data ? { json: data } : undefined,
);

// apiGet — missing the wrap
const query = params
    ? `?input=${encodeURIComponent(JSON.stringify(params))}`
    : "";

Server confirms

# Without {json:...} wrap (current CLI behavior) — fails
$ curl -sk -H "x-api-key: $TOKEN" \
    "https://panel.example.com/api/trpc/application.one?input=$(node -e 'console.log(encodeURIComponent(JSON.stringify({applicationId:"X"})))')"
{"error":{"json":{"message":"...Invalid input: expected object, received undefined...","data":{"code":"BAD_REQUEST","httpStatus":400}}}}

# With {json:...} wrap — works
$ curl -sk -H "x-api-key: $TOKEN" \
    "https://panel.example.com/api/trpc/application.one?input=$(node -e 'console.log(encodeURIComponent(JSON.stringify({json:{applicationId:"X"}})))')"
{"result":{"data":{"json":{...full app config...}}}}

Suggested fix (1 line)

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

Scope

Affects every apiGet command with arguments: *.one, *.byProjectId, *.byApplicationId, *.byComposeId, *.allByType, etc. — basically all single-item / filtered reads.

Unaffected:

  • apiPost commands (write ops like *.create, *.update, *.deploy) — already wrap correctly.
  • apiGet commands without params (project.all, application.search with no filters) — no input sent, so no wrap needed.

Happy to send a PR if maintainers prefer.

sentydeploy avatar May 13 '26 18:05 sentydeploy

I'm trying Dokploy for the first time and spent over an hour troubleshooting this before finding this thread. Huge thanks to @sentydeploy for summarizing the root cause so clearly. I would love to see a fix pushed for this soon!

ralphwest1 avatar May 20 '26 22:05 ralphwest1

Without sentydeploy's fix, the CLI has very limited application. Most of application, deployment, docker, compose, and other commands are broken. This prevents interaction with the backend without having to use GUI or building custom tooling around the API. @jcdang @hamidzr please take a look.

zhom avatar May 24 '26 13:05 zhom

Hi! Is there an ETA for a new CLI release that includes this fix? This issue is currently blocking some of our automated CI/CD workflows, so having an official build would be a huge help. We're compiling from source as a temporary workaround, but we'd love to get back to an official release whenever it's ready. Thanks for your work on this!

@Siumauricio

jaredmcqueen avatar Jul 17 '26 00:07 jaredmcqueen