Support plain text errors

Đang mở
#905 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu tại progenitor-client/src/progenitor_client.rs, đặc biệt là from_response và bound fmt::Debug của nó, sau đó tái hiện việc sinh mã từ ví dụ YAML trong issue. Được xem là hoàn tất khi client được sinh mã biên dịch được cho một phản hồi lỗi chuỗi text/plain và xử lý phản hồi đó mà không yêu cầu một bound ByteStream không được hỗ trợ.

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

Mô tả

Hi,

I have a spec where the error message is of string type and the mime type is plaintext:

/some/path:
  post:
    responses:
      '200': ...
      '500':
        description: Server error
        content:
          text/plain; charset=utf-8:
            schema:
              type: string

This gets generated into a method returning Result<ResponseValue<_>, Error<ByteStream>>. The problem happens when deserialize the response:

match response.status().as_u16() {
    200u16 => ResponseValue::from_response(response).await,
    500u16 => Err(Error::ErrorResponse(ResponseValue::stream(response))),
    _ => Err(Error::UnexpectedResponse(response)),
}

The from_response method has a bound to fmt::Debug on the error type, which is not implemented for ByteStream, thus failing compilation.

I worked around it by simply removing the bound, but I'm wondering if there's a better solution. I can also open a PR to fix it if this workaround is good.

Ngôn ngữ chính
Rust
Star
1k
Fork
142
Merge trung bình
19 giờ 13 phút
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 oxidecomputer/progenitor

Tất cả issue của oxidecomputer/progenitor

Issue tương tự

Thêm issue về Rust

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.