Skip to content

Validate handler paths during sst dev deployment#6681

Open
anatolzak wants to merge 3 commits intoanomalyco:devfrom
anatolzak:fix/validate-handler-dev-mode
Open

Validate handler paths during sst dev deployment#6681
anatolzak wants to merge 3 commits intoanomalyco:devfrom
anatolzak:fix/validate-handler-dev-mode

Conversation

@anatolzak
Copy link
Copy Markdown
Contributor

closes #6680

Summary

  • Added ValidateHandler method to the Runtime interface, implemented across all runtimes (Node, Python, Go, Rust, Worker)
  • Runtime.AddTarget RPC now validates handler paths before registering targets, so sst dev catches invalid handlers during deployment instead of at invocation time
  • Added handler validation for the bundle case in Collection.Build, which previously skipped all checks
  • Workers already performed a build step during sst dev so this was not an issue previously, but added ValidateHandler for consistency with the other runtimes

Before/After

Videos below demonstrate the developer experience for each runtime when an invalid handler path is provided. Previously, when you ran sst dev, no error appeared during deployment if you specified an invalid handler path (e.g., a non-existent file). The error only became apparent when you invoked the function. Now, the error is displayed immediately during deployment.

Lambda Node.JS

Before:

before-nodejs.mp4

After:

after-nodejs.mp4

Lambda Golang

Before:

before-golang.mp4

After:

after-golang.mp4

Lambda Python

Before:

before-python.mp4

After:

after-python.mp4

Lambda Rust

Before:

before-rust.mp4

After:

after-rust.mp4

Cloudflare Workers

Workers already performed a build step during sst dev so this was not an issue previously, but added ValidateHandler for consistency with the other runtimes.

after-worker.mp4

Test plan

  • sst dev with invalid handler path — verify error surfaces during deployment (Node, Python, Go, Rust, Workers)
  • sst dev with valid handler path — verify no regression (Node, Python, Go, Rust, Workers)
  • sst deploy with invalid handler — verify existing behavior unchanged (Node, Python, Go, Rust, Workers)
    • Note that previously with Rust only, you could provide an invalid handler (e.g., non/existent.aws-rust-lambda), but SST deploy did not throw any errors. SST essentially treated it as if you had provided the following handler: .aws-rust-lambda. Now, sst deploy will throw an error in the same way that sst dev currently does for invalid handlers.
  • sst deploy with valid handler path — verify no regression (Node, Python, Go, Rust, Workers)

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 this pull request may close these issues.

sst dev should validate handler paths during deployment, not only at invocation

1 participant