Getting "Request failed with status code 400" on every project or app request
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
After that I call dokploy project one --projectId IawXPym-JdmnSI0_g82Wa
And I have same error every time (I tried multiple projects and applications)
dokploy --version 0.3.0
same
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.
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:
apiPostcommands (write ops like*.create,*.update,*.deploy) — already wrap correctly.apiGetcommands without params (project.all,application.searchwith no filters) — no input sent, so no wrap needed.
Happy to send a PR if maintainers prefer.
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!
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.
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