Sentry-javascript: setTagsContext doesn't set tags properly

Created on 4 Dec 2017  Â·  6Comments  Â·  Source: getsentry/sentry-javascript

What is the current behavior?

When using Raven.setTagsContext to set tags in a global context, they are not properly passed to Sentry, and an error shows up in the error report stating Discarded invalid value for parameter 'tags'
sentry

What is the expected behavior?

The error report correctly shows up in Sentry.

Which versions of Raven.js, and which browser and OS are affected by this issue? Did this work in previous versions of Raven.js? Are you using the CDN (http://ravenjs.com)? Are you using hosted Sentry or on-premises? If on-premises, which version (e.g. 8.7.0)?

Following code reproduces this error, using hosted Sentry:

Raven.config("https://{public_key}@sentry.io/{app_id}").install()
Raven.setTagsContext({ release: "test version" });

throw new Error();

All 6 comments

Thanks for the report @Valandur.

Could you also post an output from the request itself?

To obtain it:

Raven.config(__your-dsn__, {
  dataCallback: function (data) {
    console.log(JSON.stringify(data, null, 2));
    return data;
  }
}).install()

Thanks!

{
  "project": "{app_id}",
  "logger": "javascript",
  "platform": "javascript",
  "request": {
    "headers": {
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
    },
    "url": "http://test.localhost/test.html"
  },
  "exception": {
    "values": [{
      "type": "Error",
      "value": "",
      "stacktrace": {
        "frames": [{
          "filename": "http://test.localhost/test.html",
          "lineno": 18,
          "colno": 9,
          "function": "?",
          "in_app": true
        }]
      }
    }]
  },
  "culprit": "http://test.localhost/test.html",
  "tags": {
    "release": "test version"
  },
  "extra": {
    "session:duration": 4
  },
  "event_id": "23c97c338bf1489ea03267e5cea6ff50"
}

I removed the project id because I wasn't sure how private that information is. Weird that it seems to show up as a correct map here, but turns into an array when sending...

release cannot be used as a tag, as it's protected attribute set via config (or setRelease method)

Please see https://docs.sentry.io/clients/javascript/config/#optional-settings

Raven.config("https://{public_key}@sentry.io/{app_id}", {
  release: "test version"
}).install();

or

Raven.config("https://{public_key}@sentry.io/{app_id}").install();
Raven.setRelease( "test version");

Yea I know about the release version used for Sentry's releases feature, but was trying to add more information in the tags. But so I'm assuming this happens due to the fact that the tag name interferes the predefined release config value?
If that's the case then consider this issue solved - maybe an error or hint wouldn't be bad when trying to use a protected tag name.

That's exactly what's happening. I'll try to send a PR to create more meaningful message so it's more obvious next time :)

@Valandur also for the reference, here's a list of protected tags – 'release', 'dist', 'user', 'filename', 'function' – https://github.com/getsentry/sentry/blob/master/src/sentry/tagstore/base.py#L19-L22

Was this page helpful?
0 / 5 - 0 ratings