Skip to content

Latest commit

 

History

History
73 lines (49 loc) · 7.74 KB

REVIEW-RULES.md

File metadata and controls

73 lines (49 loc) · 7.74 KB

Review rules for sentry-javascript

The sdk-pr-review skill reads this file. It holds the rules of this repo: the safe path in this repo for each SDK rule, the checks for tests, the light pass, and what to skip. One bullet for each rule: what to flag, why it matters, and the safe path or the exception.

Change a rule when the review gets it wrong two times for the same reason. Add a rule only for a real miss or a repeated human comment.

Rules in AGENTS.md

These sections of the root AGENTS.md are checks: "Architecture", "Coding Standards", "Testing", and "Lazy Loading Is a Last Resort". The other sections are for authors only.

  • For the stringifyForCodeInjection rule, log messages and boolean define values are fine.

SDK source in packages/

Data collection

  • Flag url.full, url.query, http.target, or request.query_string set from a URL that filterCollectedUrl() (or filterCollectedUrlQuery() for a bare query) did not filter. Pass the client when one is in scope, so dataCollection.urlQueryParams applies. The lint rule sdk/no-unfiltered-url-attributes catches a direct write, so look for a URL that goes through a helper or a variable first, a deprecated alias next to a filtered attribute, and a URL on a breadcrumb or an event. A value that cannot hold a query (a bare path, a queue URL) is fine.
  • Flag a span name built from a raw URL. A span name never holds a query string: use stripUrlQueryAndFragment().
  • Flag a SQL statement that reaches telemetry without sanitization: db.query.text, db.query.summary, the span name, and a breadcrumb. getSqlQueryAttributes() and sanitizeSqlQuery() from @sentry/server-utils sanitize, and getSqlSpanName() names the span from the sanitized attributes. Check each place the statement lands, sanitize each statement of a batch before the join, and pass the dialect (toSqlDialect()). Redis command text is not SQL and has its own path. This is not gated on dataCollection.databaseQueryData.
  • Collected data goes through the dataCollection.* options. Do not suggest a new, parallel option.

Errors and logs

  • sdk/require-exception-mechanism checks that mechanism.handled and mechanism.type are set. Check that the type value follows the rule in sdk-rules.md.
  • Flag a direct console.* call in SDK source. Use DEBUG_BUILD && debug.* for SDK diagnostics, and consoleSandbox(() => console.warn(...)) for a warning that the user must see.
  • Automatic structured logs set sentry.origin with an origin that follows the span origin rule.

Spans and attributes

  • Flag a hard-coded attribute name or span op when @sentry/conventions exports a constant for it. Use the constant from @sentry/conventions/attributes or @sentry/conventions/op. The same rule for tests is under "Tests".
  • A new attribute or op that is not in @sentry/conventions needs a link to the conventions PR that adds it. Ask for the link.
  • Flag span.setAttribute(s) right after the span starts when the value was known at the start. Pass it in the attributes option of startSpan, startSpanManual, startInactiveSpan, or startIdleSpan, because tracesSampler and ignoreSpans see only the start attributes.

Platform-safe code

  • Flag a Node-only import (fs, path, node:*, and similar) in code that ships to the browser, Cloudflare, Deno, Bun, or Vercel Edge, also through shared code in @sentry/core or @sentry/browser-utils. Put it behind a Node-only entry point.
  • Flag a top-level side effect (a call, a write to module state, an IIFE) in a module that a browser entry point reaches, also through shared code in @sentry/core or @sentry/browser-utils. It stops tree-shaking of the browser bundle. A server-only entry point is fine.
  • sdk/require-timer-unref catches a direct setTimeout or setInterval. Flag a timer through a stored reference or a helper that is not unref'd with safeUnref(), and an oxlint-disable for that rule whose reason does not hold. Such a timer keeps a CLI or script from exiting.
  • Flag a new package, or a new exports entry under packages/, that can load on a server runtime when its package has no entry in CASES or BUILD_TIME_CASES in dev-packages/bundler-tests/tests/runtime-entries.test.ts. Browser-only packages are fine.
  • Flag a new option on an incoming HTTP request integration (Node httpIntegration, Deno denoHttpIntegration and denoServeIntegration, Bun bunHttpServerIntegration and bunServerIntegration, Cloudflare httpServerIntegration) that applies to more than one runtime and is not in ServerRequestOptions (packages/core/src/integrations/http/server-request-options.ts).

Breaking changes

  • A removed public export or a changed default needs an entry in MIGRATION.md. A deprecated export needs @deprecated in its JSDoc. CHANGELOG.md is written at release time, so do not ask for an entry.

Tests

These rules apply to each test file: unit tests, and each test and test app in dev-packages/.

  • Flag a hard-coded attribute name or span op when @sentry/conventions exports a constant for it, also in an E2E test or a test app. Use the constant from @sentry/conventions/attributes or @sentry/conventions/op.
  • A fix PR has a unit, integration, or E2E test that fails without the fix. A feat PR has at least one integration or E2E test.
  • Flag a test that passes without the change: it asserts only that nothing threw, or it checks a payload with expect.objectContaining and has no assertion for the data that the change adds or removes.
  • Flag a test that waits for a request only after the action that sends it, or that depends on the order of envelopes that can arrive in any order, or that sleeps for a fixed time. Start the wait before the action, and wait on a concrete event. A short fixed wait that proves that something did not happen is fine.
  • Flag a module that loads cold inside a timed test callback when it can load at collection or in a setup hook. It can use up the timeout. Keep imports whose load time is what the test checks.
  • In dev-packages/node-integration-tests/suites/, flag a test that checks the Node version or the runtime itself (process.versions, process.env.RUNTIME, ctx.skip(), or a condition in skipIf / runIf). Use test.runIf(supports({ ... })) from utils/index.ts.
  • Flag a new Cloudflare test or E2E app variant that wraps the worker by hand with withSentry, instrumentDurableObjectWithSentry, instrumentAgentWithSentry, or instrumentWorkflowWithSentry. Use sentryCloudflareVitePlugin() from @sentry/cloudflare/vite and an instrument.server.ts that default-exports defineCloudflareOptions(...). Tests of these wrappers, and apps that do not build with Vite, are fine.

Light pass

At most 3 findings, each l and optional, each with proof:

  • Reuse: an existing helper does the same. Give its path, for example in packages/core/src/utils/ or packages/browser-utils/. A reuse with a path is allowed, though it is a refactor.
  • Dead or unnecessary logic: give the type or the caller that proves it.
  • Redundant config in tests: an option set to its default, or a default integration added again.

Skip

  • What Oxlint, Oxfmt, TypeScript, size-limit, and CI enforce. Bundle size is for the size-limit check.
  • Naming, multiple loops over one array, any and type casts, other code smells, and option or API design. Put a design question for a human into the questions for the human reviewer.
  • Secrets, ReDoS, injection, and GitHub Actions security. Other review bots check them.
  • The PR title format. CI checks it. A title type that does not match the change is still a finding.
  • Markdown files, except the MIGRATION.md check above.
  • Generated files, lockfiles, and files under a vendor/ or vendored/ folder. A lockfile change still counts when the description does not explain it.