Skip to content

'strip_common_prefix' removing too much #162

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

Closed
iBotPeaches opened this issue Jul 17, 2023 · 4 comments
Closed

'strip_common_prefix' removing too much #162

iBotPeaches opened this issue Jul 17, 2023 · 4 comments

Comments

@iBotPeaches
Copy link

Environment

v1

Steps to Reproduce

    - name: Create Sentry release
      uses: getsentry/action-release@v1
      env:
        SENTRY_ORG: redacted
      with:
        environment: ${{ inputs.env_name }}
        version: ${{ inputs.version }}
        sourcemaps: './public/js ./public/assets/js'
        strip_common_prefix: 'true'
        url_prefix: '~'

Expected Result

Files would get uploaded stripping the common prefix (ie public), but instead get stripped way too much. If we look at the directory breakdown we have:

public/assets/js/*.chunk.js
public/js/*.js

Actual Result

Screenshot 2023-07-17 at 12 04 12 PM

Basically we see it stripped way more than I expect. I would imagine the only common difference between those two above paths is up to the public part.

I expected to get files uploaded like:

  • assets/js/*.chunk.js
  • js/*.js

However, it stripped assets/js from the first and js from the 2nd. Which of course in my eyes is the reason the sourcemaps are not working

We've encountered 1 problem un-minifying your applications source code!

@philipphofmann philipphofmann transferred this issue from getsentry/sentry-fastlane-plugin Jul 18, 2023
@philipphofmann
Copy link
Member

This issue was opened at https://github.com/getsentry/sentry-fastlane-plugin, but I think it belongs here.

@iBotPeaches
Copy link
Author

thanks.

I see this is probably because the loop is just making one-off calls to the CLI - https://github.com/getsentry/action-release/blob/master/src/main.ts#L48-L60C22

Maybe that parameter was intended to be used for all the files in one directory (to clean that path). When I passed two directories and assumed it would find the common of both - thats not how its working.

Since it'll just map/format each entry in my list independently. I'll do some research into what the CLI can take, since if it can eat multiple sourcemaps at once - this might resolve itself.

However,

@szokeasaurusrex
Copy link
Member

I see this is probably because the loop is just making one-off calls to the CLI

I believe the Sentry CLI should be able to take multiple sourcemap paths at once. So, fixing might just be a matter of passing all the paths to the Sentry CLI at the same time in the plugin

@andreiborza
Copy link
Member

andreiborza commented Mar 3, 2025

Hi, the action does not make one-off calls to the CLI for sourcemaps. It does one-of calls for projects - which I think sentry-cli doesn't support otherwise.

@szokeasaurusrex sentry-cli behaves this way so it's not an action issue:

$ sentry-cli sourcemaps upload ./public/js ./public/assets/js --strip-common-prefix
...
Source Map Upload Report
  Scripts
    ~/foo.js (sourcemap at foo.js.map, debug id cfc58089-c3be-5530-b7c4-c2981ed345d1)
    ~/index.js (sourcemap at index.js.map, debug id 3086755b-d7d3-5cd0-94ae-449cb71e9dd6)
  Source Maps
    ~/foo.js.map (debug id cfc58089-c3be-5530-b7c4-c2981ed345d1)
    ~/index.js.map (debug id 3086755b-d7d3-5cd0-94ae-449cb71e9dd6)

I believe sentry-cli only strips common prefixes per source map directory supplied and not across all of them.

The solution here is to specify only ./public and let the CLI strip the common prefix in that directory which then ends up with what we expect:

$ sentry-cli sourcemaps upload ./public --strip-common-prefix
...
Source Map Upload Report
  Scripts
    ~/assets/js/foo.js (sourcemap at foo.js.map, debug id cfc58089-c3be-5530-b7c4-c2981ed345d1)
    ~/js/index.js (sourcemap at index.js.map, debug id 3086755b-d7d3-5cd0-94ae-449cb71e9dd6)
  Source Maps
    ~/assets/js/foo.js.map (debug id cfc58089-c3be-5530-b7c4-c2981ed345d1)
    ~/js/index.js.map (debug id 3086755b-d7d3-5cd0-94ae-449cb71e9dd6)

TLDR

strip_common_prefix does not work across sourcemap directories supplied and only considers common prefixes per directory.

Set a single directory and let the CLI strip away the common prefix for that:

- name: Create Sentry release
      uses: getsentry/action-release@v3
      env:
        SENTRY_ORG: redacted
      with:
        environment: ${{ inputs.env_name }}
        version: ${{ inputs.version }}
        sourcemaps: './public'
        strip_common_prefix: 'true'
        url_prefix: '~'

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

No branches or pull requests

4 participants