Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outbound HTTP to same app fails #8

Closed
itowlson opened this issue Feb 22, 2024 · 2 comments · Fixed by #10
Closed

Outbound HTTP to same app fails #8

itowlson opened this issue Feb 22, 2024 · 2 comments · Fixed by #10

Comments

@itowlson
Copy link
Contributor

itowlson commented Feb 22, 2024

Run:

spin up --build -f examples/http-outbound/

and click on the outbound-http-to-same-app: http://127.0.0.1:3000/outbound-to-hello-component link. The page returns an error and the following trace at the console:

2024-02-22T23:31:01.830361Z ERROR spin_trigger_http: Error processing request: guest invocation failed

Caused by:
    0: error while executing at wasm backtrace:
           0: 0x221c6c - wit-component:shim!indirect-wasi:http/[email protected]
           1: 0xb580 - <unknown>!spin_sdk::wit::wasi::http::outgoing_handler::handle::hcd174f5b556efe06
           2: 0x102c6 - <unknown>!spin_sdk::http::executor::outgoing_request_send::h9d5498ce413021b0
           3: 0x3e10 - <unknown>!spin_sdk::http::executor::run::h46e24987e994c893
           4: 0x7af3 - <unknown>!wasi:http/[email protected]#handle
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    1: ErrorCode::HttpRequestUriInvalid
@dicej
Copy link
Collaborator

dicej commented Feb 23, 2024

I started digging into this, adding a debug print statement to the outgoing_handler::Host::handle function in wasmtime-wasi-http. With spin-sdk 2.2.0, it works, and I see this:

req method Method::Get path Some(Scheme::Https) scheme Some("/hello") authority Some(":443")

With spin-sdk 3.0.0-pre0, it fails with the error Ivan posted above, and I see this:

req method Method::Get path Some(Scheme::Https) scheme Some("/hello") authority None

I'm guessing something subtle changed with the WASI 0.2.0 upgrade. I'll try to track it down.

@dicej
Copy link
Collaborator

dicej commented Feb 23, 2024

Okay, I figured it out. When the SDK was targeting WASI 0.2.0-rc-2023-10-18, we implicitly relied on https://github.com/fermyon/spin/blob/78f84e7fc8f19c3a516de2395a399332b6889d67/crates/core/src/wasi_2023_10_18.rs#L1893-L1896 to fill in the authority field. Now that we're targeting 0.2.0, that code isn't run anymore, so we have to handle it in the SDK instead of in the host. I'll post a PR shortly.

dicej added a commit to dicej/spin-rust-sdk that referenced this issue Feb 23, 2024
`wasi:http/outgoing-handler` requires a non-None authority for all outgoing
requests.  In the past, we relied on adapter code in the host to ensure this
(https://github.com/fermyon/spin/blob/78f84e7fc8f19c3a516de2395a399332b6889d67/crates/core/src/wasi_2023_10_18.rs#L1893-L1896),
but now that we're targeting `wasi:[email protected]` directly that code isn't used, so
we need to do it in the SDK instead.

Fixes fermyon#8

Signed-off-by: Joel Dice <[email protected]>
dicej added a commit to dicej/spin-rust-sdk that referenced this issue Feb 23, 2024
`wasi:http/outgoing-handler` requires a non-None authority for all outgoing
requests.  In the past, we relied on adapter code in the host to ensure this
(https://github.com/fermyon/spin/blob/78f84e7fc8f19c3a516de2395a399332b6889d67/crates/core/src/wasi_2023_10_18.rs#L1893-L1896),
but now that we're targeting `wasi:[email protected]` directly that code isn't used, so
we need to do it in the SDK instead.

Fixes fermyon#8

Signed-off-by: Joel Dice <[email protected]>
@dicej dicej closed this as completed in #10 Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants