Skip to content

reactComponentAnnotation creates Bad Requests (400) when fetching from external data source such as Algolia #12720

Closed

Description

@steve-rodri

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

8.11.0

Framework Version

18.3.1

Link to Sentry event

No response

SDK Setup/Reproduction Example

Sentry.init({
  dsn: "***",
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.replayIntegration(),
  ],
  environment: process.env.NODE_ENV || "local",
  // Performance Monitoring
  tracesSampleRate: 1.0, //  Capture 100% of the transactions
  // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
  tracePropagationTargets: ["localhost", SITE_URL.test, SITE_URL.production],
  // Session Replay
  replaysSessionSampleRate: process.env.NODE_ENV === "production" ? 0.1 : 1.0, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
  replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
})

Steps to Reproduce

Here is my webpack config:

const { sentryWebpackPlugin } = require("@sentry/webpack-plugin")

const { NxAppWebpackPlugin } = require("@nx/webpack/app-plugin")
const { NxReactWebpackPlugin } = require("@nx/react/webpack-plugin")

const { join } = require("path")

module.exports = {
  output: {
    path: join(__dirname, "./dist"),
  },

  devServer: {
    port: 4200,
    historyApiFallback: { index: "/" },
  },

  plugins: [
    new NxAppWebpackPlugin({
      tsConfig: "./tsconfig.app.json",
      compiler: "babel",
      main: "./src/main.tsx",
      index: "./src/index.html",
      baseHref: "/",
      assets: ["./src/favicon.ico", "./src/assets"],
      styles: ["./src/styles.scss"],
      outputHashing: process.env["NODE_ENV"] === "production" ? "all" : "none",
      optimization: process.env["NODE_ENV"] === "production",
    }),
    new NxReactWebpackPlugin({}),
    sentryWebpackPlugin({
      authToken: process.env.SENTRY_AUTH_TOKEN_FRONTEND,
      org: "v-school",
      project: "lms-react-app",
      reactComponentAnnotation: { enabled: true },
    }),
  ],

  devtool: "source-map",
}

Expected Result

When reactComponentAnnotation is enabled I should not have a response from algolia indicating a failed request of 400.

Actual Result

Screenshot 2024-07-01 at 12 48 23 PM Screenshot 2024-07-01 at 12 48 39 PM

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 1, 2024
  2. lforst commented on Jul 2, 2024

    @lforst
    Contributor

    @0Calories Would you mind taking a look at this if you got the time? Thanks!

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 2, 2024
  4. JonasBa commented on Sep 26, 2024

    @JonasBa
    Contributor

    Tagging @Haroenv - this looks like an issue on our end (prop bleeding?), thought I would expect the Algolia SDK to guard from this.

  5. smeubank commented on Sep 27, 2024

    @smeubank
    Contributor

    @JonasBa what do you mean by our end in this scenario? Sentry SDK, Algolia SDK?

  6. JonasBa commented on Sep 27, 2024

    @JonasBa
    Contributor

    @smeubank I think we generate these annotations, but then they somehow end up in Algolia, which I would expect the Algolia SDK to guard from (unless we are doing something really bad here)

  7. Haroenv commented on Oct 7, 2024

    @Haroenv

    The JS SDK will take any parameter and pass it on to the network. I guess what may happen in this case is you pass an extra prop to Configure, which then gets turned into a search parameter. As we can't know in advance what all possible parameters are, we don't have an allowlist.

    Maybe sentry needs some configuration to prevent attaching these props to certain components?

  8. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 7, 2024
  9. lforst commented on Oct 7, 2024

    @lforst
    Contributor

    @Haroenv Please see the following not as passing around a hot potato but rather from a purely technical standpoint 😂: I think it would be more reasonable if the Algolia SDK had a denylist. Our plugin runs during build and in some situations, it is semantically impossible (without doing a completely unreasonable amount of computations) to know what component we are attaching attributes to.

    cc @0Calories because he owns the annotation plugin.

  10. 5 remaining items

  11. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 8, 2024
  12. lforst commented on Oct 8, 2024

    @lforst
    Contributor

    @Haroenv You're probably right. The reality is that the vast majority of components in the ecosystem can take arbitrary properties. It is rather uncommon for components to do something with every prop passed. Especially if the props are prefixed with data-.

    We're looking into ways of making the plugin more robust - I have a hunch that it may be really hard. Of course not putting blame on anybody here.

  13. 0Calories commented on Oct 8, 2024

    @0Calories
    Contributor

    I'm working on getsentry/sentry-javascript-bundler-plugins#617 which will add a configuration to specify components that should not have annotations applied. Users have brought up incompatibilities with other libraries so I do think it is important to have this option available on Sentry's side as well

  14. lforst commented on Oct 9, 2024

    @lforst
    Contributor

    We could even have a list of components as a default, that we know are potentially problematic.

  15. paulgrieselhuber commented on Jan 8, 2025

    @paulgrieselhuber

    fwiw on a next.js project in next.config.js I added:

    reactComponentAnnotation: {
        enabled: false,
      },

    as it was breaking site-wide search entirely. When possible will re-enable.

  16. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jan 8, 2025
  17. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jan 8, 2025
  18. andreiborza commented on Mar 7, 2025

    @andreiborza
    Member

    You now can either disable react component annotation entirely or mark components you want to ignore by setting

    reactComponentAnnotation: {
       enabled: true,
       ignoredComponents: ['ComponentAToIgnore', 'ComponentBToIgnore', ..]
    }
    

    I'll close this issue, if this still causes problems feel free to file a new issue.

  19. ghost added on Aug 12, 2025
  20. mikehwagz commented on Oct 3, 2025

    @mikehwagz

    In case it wasn't already extremely clear, just wanted to leave this here for future folks facing this issue like I just did. The fix for me was simply:

    reactComponentAnnotation: {
       enabled: true,
       ignoredComponents: ['Configure']
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions