wing icon indicating copy to clipboard operation
wing copied to clipboard

fix(sdk)!: change `cloud.Function` event type from `string` to `Json`

Open garysassano opened this issue 1 year ago • 4 comments

Closes #6216

BREAKING CHANGE: The input type for cloud.Function handlers has been changed from string to Json to align with the event formats used by major cloud providers like AWS, GCP, and Azure.

This is a breaking change for any existing code that assumes the input event is a string.

To migrate:

  • Update cloud.Function handlers to expect a Json value as input instead of a string
  • Remove any JSON parsing logic since the input will already be parsed into a Json value
  • Update any tests or invocations of cloud.Function to pass in Json values instead of string

Checklist

  • [x] Title matches Winglang's style guide
  • [x] Description explains motivation and solution
  • [ ] Tests added (always)
  • [ ] Docs updated (only required for features)
  • [ ] Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

garysassano avatar Apr 12 '24 06:04 garysassano

Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistence, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon

github-actions[bot] avatar Apr 12 '24 06:04 github-actions[bot]

Please add a detailed description and a BREAKING CHANGE section to the PR description

eladb avatar Apr 12 '24 14:04 eladb

The function invocation on AWS works now.

❯ aws lambda invoke --function-name Function-c852aba6 --payload $(echo '{ "foo": 123 }' | base64)  out.json
{
    "StatusCode": 200,
    "ExecutedVersion": "$LATEST"
}

garysassano avatar Apr 13 '24 14:04 garysassano

Hi,

This PR has not seen activity in 20 days. Therefore, we are marking the PR as stale for now. It will be closed after 7 days. If you need help with the PR, do not hesitate to reach out in the winglang community discord at winglang.discord.com. Feel free to re-open this PR when it is still relevant and ready to be worked on again. Thanks!

github-actions[bot] avatar May 04 '24 06:05 github-actions[bot]

Hi,

This PR has not seen activity in 20 days. Therefore, we are marking the PR as stale for now. It will be closed after 7 days. If you need help with the PR, do not hesitate to reach out in the winglang community Discord. Feel free to re-open this PR when it is still relevant and ready to be worked on again. Thanks!

github-actions[bot] avatar Jun 05 '24 06:06 github-actions[bot]

Hi Gary, do you need any help with this one? Can you please resolve the conflicts?

tsuf239 avatar Jun 05 '24 07:06 tsuf239

I resolved the conflicts, but I don't have much knowledge on how the simulator resources work. Some of them require type adjusting.

garysassano avatar Jun 06 '24 00:06 garysassano

it seems like there are many compilation errors: image I think you can reproduce it by running "pnpm run compile" at the SDK folder

tsuf239 avatar Jun 06 '24 12:06 tsuf239

Hey Gary, I wanted to give a heads up I've started working on update this PR and fix up some of the remaining tests. Stay tuned!

Chriscbr avatar Jun 10 '24 14:06 Chriscbr

Console preview environment is available at https://wing-console-pr-6219.fly.dev :rocket:

Last Updated (UTC) 2024-07-16 20:41

monadabot avatar Jun 13 '24 21:06 monadabot

Hi,

This PR has not seen activity in 20 days. Therefore, we are marking the PR as stale for now. It will be closed after 7 days. If you need help with the PR, do not hesitate to reach out in the winglang community Discord. Feel free to re-open this PR when it is still relevant and ready to be worked on again. Thanks!

github-actions[bot] avatar Jul 05 '24 06:07 github-actions[bot]

@Chriscbr , @garysassano - what is the status of this one?

revitalbarletz avatar Jul 09 '24 08:07 revitalbarletz

@revitalbarletz A few other features got bumped up in priority so I had to put my work on this on pause, but I'm aiming to update the PR and try doing some more testing for it later this week.

Chriscbr avatar Jul 09 '24 16:07 Chriscbr

:x: Unstable Self-Mutation :x:

Self-mutation has run twice in a row. There may be a something non-deterministic in the build or test process. Check the last mutation commit (1a232aeb1ee3b58e0cbcdc0491322e9c9ccb9a5c) for suspicious changes. This is typically caused by:

  • Absolute paths
  • Timestamps
  • Random values
  • Flakey tests (relying on one of the above)

monadabot avatar Jul 11 '24 18:07 monadabot

SDK spec tests: https://github.com/winglang/wing/actions/runs/9913437025

Chriscbr avatar Jul 12 '24 21:07 Chriscbr

Attempt fixing Azure tests: https://github.com/winglang/wing/actions/runs/9914506779

Chriscbr avatar Jul 12 '24 21:07 Chriscbr

Benchmarks

Comparison to Baseline ⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜🟥⬜
Benchmark Before After Change
version 58ms±0.36 58ms±0.83 0ms (-0.03%)⬜
functions_10.test.w -t sim 523ms±16.7 506ms±20.36 -17ms (-3.21%)⬜
functions_10.test.w -t tf-aws 2232ms±22.94 2208ms±20.39 -24ms (-1.09%)⬜
jsii_small.test.w -t sim 382ms±2.49 389ms±2.83 +6ms (+1.62%)⬜
jsii_small.test.w -t tf-aws 634ms±6.2 645ms±5.93 +11ms (+1.74%)⬜
jsii_big.test.w -t sim 2989ms±11.83 3024ms±13.1 +34ms (+1.15%)⬜
jsii_big.test.w -t tf-aws 3166ms±13.62 3210ms±27.9 +44ms (+1.39%)⬜
hello_world.test.w -t sim 405ms±3.68 414ms±4.31 +9ms (+2.11%)⬜
hello_world.test.w -t tf-aws 1493ms±5.84 1503ms±8.82 +10ms (+0.64%)⬜
empty.test.w -t sim 366ms±2.53 373ms±3.84 +7ms (+1.78%)⬜
empty.test.w -t tf-aws 620ms±2.7 625ms±5.73 +5ms (+0.79%)⬜
functions_1.test.w -t sim 404ms±4.74 419ms±9.4 +15ms (+3.73%)🟥
functions_1.test.w -t tf-aws 857ms±5.36 868ms±6.95 +11ms (+1.3%)⬜

⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 58ms 57ms 60ms 1ms 1ms
functions_10.test.w -t sim 506ms 471ms 548ms 20ms 28ms
functions_10.test.w -t tf-aws 2208ms 2165ms 2254ms 20ms 29ms
jsii_small.test.w -t sim 389ms 384ms 395ms 3ms 4ms
jsii_small.test.w -t tf-aws 645ms 629ms 657ms 6ms 8ms
jsii_big.test.w -t sim 3024ms 2993ms 3057ms 13ms 18ms
jsii_big.test.w -t tf-aws 3210ms 3156ms 3298ms 28ms 39ms
hello_world.test.w -t sim 414ms 405ms 425ms 4ms 6ms
hello_world.test.w -t tf-aws 1503ms 1478ms 1519ms 9ms 12ms
empty.test.w -t sim 373ms 363ms 379ms 4ms 5ms
empty.test.w -t tf-aws 625ms 614ms 638ms 6ms 8ms
functions_1.test.w -t sim 419ms 403ms 449ms 9ms 13ms
functions_1.test.w -t tf-aws 868ms 858ms 888ms 7ms 10ms
Last Updated (UTC) 2024-07-15 20:17

monadabot avatar Jul 15 '24 20:07 monadabot

Thanks for contributing, @garysassano! This PR will now be added to the merge queue, or immediately merged if gary/funtion-json-handler is up-to-date with main and the queue is empty.

mergify[bot] avatar Jul 17 '24 15:07 mergify[bot]

Congrats! :rocket: This was released in Wing 0.79.0.

monadabot avatar Jul 17 '24 16:07 monadabot