Repository: cargo-lambda/cargo-lambda (language: python)

Issue:
When setting ENV variables in Cargo.toml, an integer value will cause all values to be missing with no error
Recently, I was experimenting with `RUST_BACKTRACE` and particularly tried to explicitly set `RUST_BACKTRACE=1` in the metadata section of `Cargo.toml` for ```cargo lambda watch``` to grab from the env. While the `Cargo.toml` file was still valid, and no errors were thrown around this in `cargo lambda watch`, all environment variables in the metadata section were now missing at runtime.

ie: I have a lambda that depends on `AWS_REGION` and previously was passing it to the lambda locally like so:
```
[package.metadata.lambda.bin.api.env]
AWS_REGION="us-west-2"
```
I access the variable using `let region = std::env::var("AWS_REGION").expect("MISSING REGION")`

When I updated to this, AWS_REGION was missing:
```
[package.metadata.lambda.bin.api.env]
AWS_REGION="us-west-2"
RUST_BACKTRACE=1
```

I was in the midst of lots of other changes and didn't immediately notice that this caused my issue, and it would have been great if `watch` warned me of this. 



Discussion / hints:
👋 Thanks for opening this issue!

  @calavera is taking a break for health issues. He'll be back online in a few weeks.
  If you're having issues building your Lambda functions, take a look at old [closed issues](https://github.com/cargo-lambda/cargo-lambda/issues?q=is%3Aissue), you might find an answer to your problem there.

Fix patch:
diff --git a/crates/cargo-lambda-metadata/src/cargo.rs b/crates/cargo-lambda-metadata/src/cargo.rs
index e8a7058f..5e4f6add 100644
--- a/crates/cargo-lambda-metadata/src/cargo.rs
+++ b/crates/cargo-lambda-metadata/src/cargo.rs
@@ -520,6 +520,13 @@ mod tests {
         assert_eq!(env.get("BAZ").unwrap(), "QUX");
     }
 
+    #[test]
+    fn test_invalid_metadata() {
+        let result =
+            function_environment_metadata(fixture("missing-binary-package"), Some("get-products"));
+        assert!(result.is_err());
+    }
+
     #[test]
     fn test_metadata_workspace_packages() {
         let env =
diff --git a/crates/cargo-lambda-watch/src/lib.rs b/crates/cargo-lambda-watch/src/lib.rs
index ce4c1567..fe10816b 100644
--- a/crates/cargo-lambda-watch/src/lib.rs
+++ b/crates/cargo-lambda-watch/src/lib.rs
@@ -10,7 +10,7 @@ use opentelemetry::{
 use opentelemetry_aws::trace::XrayPropagator;
 use std::{
     net::{IpAddr, SocketAddr},
-    path::{PathBuf, Path},
+    path::{Path, PathBuf},
     str::FromStr,
 };
 use tokio::time::Duration;
@@ -22,7 +22,7 @@ use tower_http::{
     trace::TraceLayer,
 };
 
-use tracing::{info, Subscriber, trace};
+use tracing::{info, trace, Subscriber};
 use tracing_opentelemetry::OpenTelemetryLayer;
 use tracing_subscriber::registry::LookupSpan;
 
@@ -161,7 +161,8 @@ impl Watch {
 async fn discover_ignore_files(base: &Path) -> Vec<ignore_files::IgnoreFile> {
     let mut ignore_files = Vec::new();
 
-    let (mut env_ignore, env_ignore_errs) = ignore_files::from_environment(Some("CARGO_LAMBDA")).await;
+    let (mut env_ignore, env_ignore_errs) =
+        ignore_files::from_environment(Some("CARGO_LAMBDA")).await;
     trace!(ignore_files = ?env_ignore, errors = ?env_ignore_errs, "discovered ignore files from environment variable");
     ignore_files.append(&mut env_ignore);
 
diff --git a/crates/cargo-lambda-watch/src/watcher.rs b/crates/cargo-lambda-watch/src/watcher.rs
index 33733a6b..368ff114 100644
--- a/crates/cargo-lambda-watch/src/watcher.rs
+++ b/crates/cargo-lambda-watch/src/watcher.rs
@@ -2,7 +2,7 @@ use crate::{error::ServerError, requests::NextEvent, state::ExtensionCache};
 use cargo_lambda_metadata::cargo::function_environment_metadata;
 use ignore_files::{IgnoreFile, IgnoreFilter};
 use std::{collections::HashMap, convert::Infallible, path::PathBuf, sync::Arc, time::Duration};
-use tracing::{debug, error, trace, warn};
+use tracing::{debug, error, trace};
 use watchexec::{
     action::{Action, Outcome, PreSpawn},
     command::Command,
@@ -181,7 +181,7 @@ async fn runtime(
 
             let env = function_environment_metadata(manifest_path, bin_name.as_deref())
                 .map_err(|err| {
-                    warn!(error = %err, "ignoring invalid function metadata");
+                    error!(error = %err, "invalid function metadata");
                     err
                 })
                 .unwrap_or_default();


Test patch:
diff --git a/tests/fixtures/missing-binary-package/Cargo.toml b/tests/fixtures/missing-binary-package/Cargo.toml
index 0886e7de..9a92301c 100644
--- a/tests/fixtures/missing-binary-package/Cargo.toml
+++ b/tests/fixtures/missing-binary-package/Cargo.toml
@@ -11,3 +11,7 @@ serde = "1.0.136"
 tokio = { version = "1.17.0", features = ["full"] }
 tracing = "0.1.32"
 tracing-subscriber = "0.3.9"
+
+[package.metadata.lambda.bin.basic-lambda.env]
+AWS_REGION = "us-west-2"
+RUST_BACKTRACE = 1