Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite production build failed due to SENTRY_RELEASE containing double quotes #584

Closed
kenn opened this issue Aug 9, 2024 · 3 comments · Fixed by #585
Closed

Vite production build failed due to SENTRY_RELEASE containing double quotes #584

kenn opened this issue Aug 9, 2024 · 3 comments · Fixed by #585
Assignees

Comments

@kenn
Copy link

kenn commented Aug 9, 2024

Environment

Latest everything

Steps to Reproduce

  1. Set git commit as release string with process.env.SENTRY_RELEASE = execSync('git log -1 --pretty=%B')
  2. Get error on production build with a following error:
_global.SENTRY_RELEASE={id:"commit containing "double quotes""};

Expected Result

If it's stored in a JSON, double quotes should be escaped appropriately.

Actual Result

Image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Aug 9, 2024
@lforst
Copy link
Member

lforst commented Aug 12, 2024

Thanks for reporting. We should fix this. I wonder though whether Sentry itself supports quotes in releases. In any case this should probably not crash the build though.

@lforst
Copy link
Member

lforst commented Aug 12, 2024

Small note though: You're assigning a buffer to process.env. SENTRY_RELEASE which is probably not the best idea 😄 Maybe do .toString() or decode as utf8 so that it becomes a string.

@kenn
Copy link
Author

kenn commented Aug 12, 2024

Thanks for the quick fix!

That was for reporting abbreviation and this was the actual code, for anyone who finds it useful.

// Get the git info
const DATE = execSync(
  "git log -1 --date=format:'%Y-%m-%d' --pretty=format:'%ad'",
)
  .toString()
  .trim()
const MESSAGE = execSync('git log -1 --pretty=%B')
  .toString()
  .trim()
  .split('\n')[0]
  .slice(0, 20)
const HASH = execSync('git rev-parse --short HEAD').toString().trim()
process.env.SENTRY_RELEASE = `${DATE} ${MESSAGE} - ${HASH}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants