-
Notifications
You must be signed in to change notification settings - Fork 282
Open
Description
Currently, the spin up
command does not check if required variables are provided when launching the application.
Consider a Spin application with the following manifest:
spin_manifest_version = 2
[application]
name = "test"
version = "0.1.0"
description = ""
[variables]
foo = { required = true }
[[trigger.http]]
route = "/..."
component = "test"
[component.test]
source = "target/wasm32-wasip1/release/test.wasm"
allowed_outbound_hosts = []
[component.test.variables]
foo = "{{foo}}"
[component.test.build]
command = "cargo build --target wasm32-wasip1 --release"
watch = ["src/**/*.rs", "Cargo.toml"]
use spin_sdk::http::{IntoResponse, Request, Response};
use spin_sdk::{http_component, variables};
#[http_component]
fn handle_test_var(_: Request) -> anyhow::Result<impl IntoResponse> {
match variables::get("foo") {
Ok(value) => println!("{}", value),
Err(r) => println!("{}", r),
};
Ok(Response::new(200, ()))
}
Expected behavior
I expect spin up
to bail out and prevent from launching the app - if the required variable foo
is not specified (e.g., by setting the SPIN_VARIABLE_FOO
environment variable)
Actual behavior
I can start the app locally using spin up
. Sending a request to the app (which tries to load the foo
variable will result in a runtime error:
Error::Provider("no provider resolved required variable \"foo\"")
Spin Version
I see this behavior with current spin version (tested 3.0.0
, 3.1.2
and 3.2.0
)
vdice, macolso and seun-ja
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Investigating / Open For Comment