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

Đang mở Phù hợp với người mới
#48 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, cli

Hướng nghiên cứu

Bắt đầu trong src/client.ts và so sánh apiGet với các quy ước về tham số truy vấn trong openapi.json. Chạy một lệnh có tham số như dokploy compose one --composeId <valid-id> --json, sau đó kiểm tra rằng các lệnh GET sử dụng các khóa truy vấn có tên và trả về thành công thay vì thất bại với trạng thái 400.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).

Ngôn ngữ chính
TypeScript
Star
152
Fork
46
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Dokploy/cli

Tất cả issue của Dokploy/cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.