6

I'm trying to deploy a lambda@edge function (an AWS Lambda function that modifies HTML coming from a Cloudfront distribution) and get this cryptic response on save:

enter image description here

Does anyone know what Cannot read properties of undefined (reading 'startsWith') is referring to here, or how I can resolve this? Any pointers would be helpful!

duhaime
  • 25,611
  • 17
  • 169
  • 224
  • Can you share the piece of code that calls `.startsWith()` function? – Vlad Holubiev Oct 12 '22 at 13:01
  • My lambda function didn't contain `.startsWith()` -- I don't know where AWS got that from. This was my function: https://gist.githubusercontent.com/duhaime/8279aa0eb09826254f76762b6f4195b0/raw/bc0ce076de547473624c4e39739208a83d5e792d/basic.js This seems like a bug on the AWS side, possibly after account login expire. I logged out, logged back in, and the same request that was throwing this error prior succeeded... – duhaime Oct 16 '22 at 13:21

1 Answers1

4

Seems like an issue with form validation. Just toggling any of the menu item(like origin req to origin res and back to origin req) is forcing a revalidation and then you can submit the form.

  • When this was triggering, I tried changing each of the form elements and got the same result. Are you able to reproduce this and then submit the form by changing an element in the form? If so and you describe what you did I'm happy to give you the bounty! – duhaime Oct 19 '22 at 18:44
  • 1
    Yes, the behaviour was reproducible. I know a developer who did another workaround by simply doing the same things in a new tab. The issue has already been reported to support. – Maneesh P M Oct 26 '22 at 16:14
  • When you say toggling a menu item forces a revalidation, do you mean you interact with a menu item **after** re-authenticating to make the form valid / submittable? – duhaime Oct 26 '22 at 19:47
  • Yes, for some reason it worked only when the menu was toggled after re-authentication. – Maneesh P M Oct 27 '22 at 00:08
  • Right, this is what I had suggested in my comment above. Thanks for reporting this to the AWS team (or for at least indicating it had been reported)! – duhaime Oct 27 '22 at 10:21
  • Quick update, this is still an active issue and toggling the input option still fixes it, so even if AWS is aware of this, they still haven't fixed it. – Dids Jun 12 '23 at 12:25