getsentry / sentry-migr8

Migrate your Sentry SDK usage to v8.
MIT License
2 stars 0 forks source link

Transformation error (Unexpected token) and wrong behaviours #52

Open DarthGigi opened 1 month ago

DarthGigi commented 1 month ago

Environment

Svelte/Kit

Steps to Reproduce

  1. Run pnpx @sentry/migr8@latest
  2. Select Apply all transformations

Expected Result

The migrate command changes the files that are actually necessary to be changed and in the right way

Actual Result

For each component I have in my routes folder, I get the following error:

ERR /src/routes/bug-report.svelte Transformation error (Unexpected token (34:1))
SyntaxError: Unexpected token (34:1)

This is because for some reason </string> is being added just before </script> when transforming the files: Screenshot 2024-05-16 at 9  43 31@2x

This doesn't happen in sveltekit's route files (+layout and +page.svelte) files, however, it does in +error.svelte files.

Another thing is that for some reason it tries to "fix" self-closing elements. If we have <div /> for example, it changes it to <div></div>, while it is true that <div /> is not valid HTML, this should not apply to components:

Screenshot 2024-05-16 at 9  51 53@2x

Why is Sentry changing my markup? Isn't it supposed to just change it's own stuff and only in <script> tags?

Another thing you can see in the screenshot is that Sentry added </svelte:window> to the bottom of the file:

  1. <svelte:window/> does not accept children, so it must be always closed/self closed without anything as it's child
  2. <svelte:window/> is already closed, why does Sentry think it's not?

This migrate command changed about 170 files (mostly .svelte files since I'm using shadcn svelte components) which makes it not worth going over the stuff that Sentry changed to actually migrate from v7 to v8 and to check if there are any todo's left.

Feel free to change the title of this issue to a more fitting one.

Lms24 commented 1 month ago

Hey @DarthGigi thanks for writing in and apologies for the late reply!

Why is Sentry changing my markup? Isn't it supposed to just change it's own stuff and only in when transforming the files

Hmm that's also a weird one. I'll check what's going wrong here.

Florinstruct commented 3 weeks ago

Same here. Migration script deletes or rewrites random seeming sections of our codebase. I tried to figure out which option ("transformer") is responsible, but more than one seem to trigger this.

Even if you only Add migration comments, the script will rewrite over 400 files and break 150 of them.

image