fermyon / spin-dotnet-sdk

Apache License 2.0
43 stars 11 forks source link

Fix sample project wizer-ization #49

Closed jpflueger closed 1 year ago

jpflueger commented 1 year ago

I was experimenting with the dotnet sdk and saw that the sample projects would fail wizer initialization because it's missing headers that are typically provided by spin's http trigger.

spin build --up
Executing the build command for component hello: dotnet build -c Release
MSBuild version 17.6.0-preview-23106-07+fc3ab4c5e for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
/usr/local/share/dotnet/sdk/8.0.100-preview.2.23108.9/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/Users/j12r/Development/fermyon/spin-dotnet-sdk/samples/hello-world/HelloWorld.Spin.csproj]
  Fermyon.Spin.Sdk -> /Users/j12r/Development/fermyon/spin-dotnet-sdk/src/bin/Release/net7.0/Fermyon.Spin.Sdk.dll
  Fermyon.Spin.Sdk -> /Users/j12r/Development/fermyon/spin-dotnet-sdk/src/bin/Release/net7.0/Fermyon.Spin.Sdk.wasm
  HelloWorld.Spin -> /Users/j12r/Development/fermyon/spin-dotnet-sdk/samples/hello-world/bin/Release/net7.0/HelloWorld.Spin.dll
  HelloWorld.Spin -> /Users/j12r/Development/fermyon/spin-dotnet-sdk/samples/hello-world/bin/Release/net7.0/HelloWorld.Spin.wasm
  Running wizer to preinitialize bin/Release/net7.0/HelloWorld.Spin.wasm...

  Unhandled Exception:
  System.Collections.Generic.KeyNotFoundException: spin-full-url
     at Fermyon.Spin.Sdk.HttpKeyValues.get_Item(String key)
     at Fermyon.Spin.HelloWorld.Handler.EchoRequestInfo(HttpRequest request)
     at Fermyon.Spin.HelloWorld.Handler.HandleHttpRequest(HttpRequest request)

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.94
Successfully ran the build command for the Spin components.

I was wondering if it would be an acceptable improvement to provide fake headers to the warmup request in case components aren't necessarily checking for /warmupz url? I went ahead and got it working on my machine so I thought I'd start the discussion with the approach. Another alternative could be to make the sample project tolerant of missing headers which I'm happy to pivot to as well.