spinframework / spinframework/spin-rust-sdk

Misleading docs on P3 resurfaced `http::Response::new()`

Open
#98 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
35
Forks
23
Avg merge
37m
Merged PRs (30d)
1

Description

Create the following Spin SDK P3 handler:

#[spin_sdk::http_wasip3::http_service]
async fn handle(_request: Request) -> impl IntoResponse {
    spin_sdk::http_wasip3::Response::new("done\n")
}

Rust gets mad at you:

Image

Scroll down the docs to see what you are allowed to pass to new and:

Image

It's confusing that the docs show an example of passing an &str but you're not actually allowed to. Unfortunately the Response type is a re-export so we don't control the docs.

Amusingly, you can return an &str directly...

#[spin_sdk::http_wasip3::http_service]
async fn handle(_request: Request) -> impl IntoResponse {
    "done\n"
}

...you just can't use one in a Response.

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 by reading the P3 handler example and the documentation for spin_sdk::http_wasip3::Response::new, then verify where the re-exported Response documentation is generated or maintained. Done means the documented argument matches what the example accepts, or the example no longer presents an invalid &str usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.