oxidecomputer / oxidecomputer/progenitor

Support plain text errors

Open
#905 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1k
Forks
136
Avg merge
8h 36m
Merged PRs (30d)
14

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at progenitor-client/src/progenitor_client.rs, especially from_response and its fmt::Debug bound, then reproduce generation from the YAML example in the issue. Done means the generated client compiles for a text/plain string error response and handles that response without requiring an unsupported ByteStream bound.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.