spin icon indicating copy to clipboard operation
spin copied to clipboard

Outbound HTTP component ignores `params` field

Open itowlson opened this issue 1 year ago • 10 comments

http-types.wit defines the request type to have a member params which is documented as // The HTTP parameter queries, represented as a list of (name, value) pairs.

If you set this on an outbound request, it is ignored - no query string is included the URL.

We should either respect params, or remove it from the outbound request type.

itowlson avatar Jul 26 '22 03:07 itowlson

remove it from the outbound request type

We should consider removing it entirely (moving it into SDKs); param parsing can be subtly different in different languages.

lann avatar Aug 01 '22 15:08 lann

One thing to consider if removing is that we are reusing the HTTP request and response type definitions across the HTTP trigger and the outbound HTTP implementation.

radu-matei avatar Aug 01 '22 15:08 radu-matei

Yeah, I'm suggesting removing it from everywhere. Using url form encoding for params is "just" a (very common) convention.

lann avatar Aug 01 '22 15:08 lann

this is also impacting tweet embedding in bartholomew.

if i understand correctly, the consensus is to remove the params parameter from wit types file and make corresponding changes in sdk's?

rajatjindal avatar Aug 25 '22 08:08 rajatjindal

If we're removing params this is not a good first issue.

lann avatar Aug 25 '22 21:08 lann

For outbound HTTP the params field is currently non-functional but it looks like the query part of the request URI should be working; at least, I don't see in the code that it is being removed.

lann avatar Aug 25 '22 21:08 lann

Current behaviour from testing:

  • Inbound
    • The original query string is included in url
    • The params field is populated
  • Outbound
    • If you include a query string in url it is preserved verbatim (as Lann predicted)
    • If you set params it is ignored

itowlson avatar Aug 29 '22 00:08 itowlson

  • Inbound
    • The original query string is included in url

Well that's good. I propose we:

  1. Switch our SDKs to use only the query for both inbound and outbound
  2. Document that params is deprecated
  3. Drop params the next time we make breaking changes to the http interfaces (after streams support lands, if not sooner)

lann avatar Aug 29 '22 14:08 lann

I will send a PR for 1 and 2.

itowlson avatar Aug 29 '22 21:08 itowlson

Slight correction: if you include a query string on an outbound request, Spin leaves it alone. But if you're using the Rust SDK, that strips it out (before passing the request to Spin).

itowlson avatar Aug 30 '22 01:08 itowlson