oxidecomputer / oxidecomputer/progenitor

Generated httpmock Then.ok & .json_body_obj compile issues

Open
#637 7 comments 0 reactions 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

When I attempt to compile the generated output, I see

error[E0308]: mismatched types
   --> src/propolis_server_httpmock.rs:302:39
    |
302 |             Self(self.0.json_body_obj(value))
    |                         ------------- ^^^^^ expected `&_`, found `InstanceStateRequested`
    |                         |
    |                         arguments to this method are incorrect
    |
    = note: expected reference `&_`
                    found enum `propolis_server_builder::types::InstanceStateRequested`
note: method defined here
   --> /home/jayvdb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/httpmock-0.6.8/src/api/spec.rs:534:12
    |
534 |     pub fn json_body_obj<'a, T>(self, body: &T) -> Self
    |            ^^^^^^^^^^^^^
help: consider borrowing here
    |
302 |             Self(self.0.json_body_obj(&value))
    |                                       +

Some errors have detailed explanations: E0308, E0433.
For more information about an error, try `rustc --explain E0308`.

when I add & as suggested, I get errors like

error[E0277]: the trait bound `&propolis_server_builder::types::InstanceStateMonitorRequest: Deserialize<'_>` is not satisfied
   --> src/propolis_server_httpmock.rs:356:39
    |
356 |             Self(self.0.json_body_obj(&value))
    |                         ------------- ^^^^^^ the trait `Deserialize<'_>` is not implemented for `&propolis_server_builder::types::InstanceStateMonitorRequest`
    |                         |
    |                         required by a bound introduced by this call
    |
note: required by a bound in `When::json_body_obj`
   --> /home/jayvdb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/httpmock-0.6.8/src/api/spec.rs:536:24
    |
534 |     pub fn json_body_obj<'a, T>(self, body: &T) -> Self
    |            ------------- required by a bound in this associated function
535 |     where
536 |         T: Serialize + Deserialize<'a>,
    |                        ^^^^^^^^^^^^^^^ required by this bound in `When::json_body_obj`
help: consider removing the leading `&`-reference
    |
356 -             Self(self.0.json_body_obj(&value))
356 +             Self(self.0.json_body_obj(value))
    |

This is a rabbit hole, as adding #derive[serde::Deserialize, serde::Serialize] then requires Client has those traits, etc.

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 with the generated src/propolis_server_httpmock.rs and compare the Then.ok and json_body_obj calls with httpmock 0.6.8's When::json_body_obj signature. Reproduce the reported compilation errors, then trace the generator entry point that emits these methods and verify the generated output compiles without requiring unsuitable Serialize or Deserialize implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.