Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(error-tracking): show access denied instead of 403s in configuration (#70533)

Aleksander Błaszkiewicz1634816e15a8
diff --git a/common/storybook/.storybook/app-context.ts b/common/storybook/.storybook/app-context.ts
index 64c6a0bc9621..c0419e98338a 100644
--- a/common/storybook/.storybook/app-context.ts
+++ b/common/storybook/.storybook/app-context.ts
@@ -90,5 +90,6 @@ export const getStorybookAppContext = (): AppContext => ({
activity_log: 'viewer',
customer_analytics: 'manager',
llm_analytics: 'manager',
+ error_tracking: 'manager',
},
})
diff --git a/frontend/src/lib/utils/accessControlUtils.ts b/frontend/src/lib/utils/accessControlUtils.ts
index 55ab8432b3ba..8fcdc588420b 100644
--- a/frontend/src/lib/utils/accessControlUtils.ts
+++ b/frontend/src/lib/utils/accessControlUtils.ts
@@ -116,6 +116,8 @@ export const resourceTypeToString = (resourceType: AccessControlResourceType): s
return 'revenue analytics resource'
} else if (resourceType === AccessControlResourceType.WebAnalytics) {
return 'web analytics resource'
+ } else if (resourceType === AccessControlResourceType.ErrorTracking) {
+ return 'error tracking resource'
} else if (resourceType === AccessControlResourceType.ExternalDataSource) {
return 'data warehouse source'
} else if (resourceType === AccessControlResourceType.Workflow) {
diff --git a/frontend/src/scenes/settings/Settings.tsx b/frontend/src/scenes/settings/Settings.tsx
index f403da2ce9d9..4e2f5c9ff221 100644
--- a/frontend/src/scenes/settings/Settings.tsx
+++ b/frontend/src/scenes/settings/Settings.tsx
@@ -8,6 +8,7 @@ import React from 'react'
import { IconExternal, IconList } from '@posthog/icons'
import { LemonButton, LemonDivider, Link } from '@posthog/lemon-ui'
+import { AccessDenied } from 'lib/components/AccessDenied'
import { NotFound } from 'lib/components/NotFound'
import { SupportedPlatforms } from 'lib/components/SupportedPlatforms/SupportedPlatforms'
import { TimeSensitiveAuthenticationArea } from 'lib/components/TimeSensitiveAuthentication/TimeSensitiveAuthentication'
@@ -65,6 +66,7 @@ export function Settings({
}): JSX.Element {
const {
selectedSectionId,
+ selectedSection,
selectedLevel,
selectedSettingId,
settings,
@@ -110,6 +112,15 @@ export function Settings({
// in normal flow instead, so it sits beside the content rather than overlapping.
const isFullScene = props.logicKey === 'settingsScene'
+ // Sections gated by access control render a generic denial instead of their settings,
+ // which would otherwise mount and immediately 403 against their endpoints.
+ const sectionAccessDeniedReason = selectedSection?.accessControl
+ ? getAccessControlDisabledReason(
+ selectedSection.accessControl.resourceType,
+ selectedSection.accessControl.minimumAccessLevel
+ )
+ : null
+
// When embedded in a specific section (replay, logs, error tracking, etc. — anything that
// passes a `sectionId`), the nav always lists that section's settings as in-context sub-tabs.
// It must NOT depend on `selectedSetting` resolving: that value is derived from asynchronously
@@ -330,9 +341,13 @@ export function Settings({
</Combobox>
)
+ // Embeds show only the denied section's sub-tabs, so hide the nav along with the content.
+ // The full settings scene keeps its nav so other sections stay reachable.
+ const hideNav = hideSections || (settingsInSidebar && !!sectionAccessDeniedReason)
+
return (
<div className={clsx('Settings flex items-start', isCompact && 'Settings--compact')}>
- {hideSections ? null : isCompact ? (
+ {hideNav ? null : isCompact ? (
<>
<Button variant="outline" left className="w-full" onClick={() => openCompactNavigation()}>
<IconList className="stroke-2 size-4 mr-1" />{' '}
@@ -386,7 +401,11 @@ export function Settings({
<AuthenticationAreaComponent>
<div className="space-y-2">
{headerSlot}
- <SettingsRenderer {...props} handleLocally={handleLocally} />
+ {sectionAccessDeniedReason ? (
+ <AccessDenied reason={sectionAccessDeniedReason} />
+ ) : (
+ <SettingsRenderer {...props} handleLocally={handleLocally} />
+ )}
</div>
</AuthenticationAreaComponent>
</div>
diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx
index 8ea1892bd79a..aaa17f671fd2 100644
--- a/frontend/src/scenes/settings/SettingsMap.tsx
+++ b/frontend/src/scenes/settings/SettingsMap.tsx
@@ -433,6 +433,10 @@ export const SETTINGS_MAP: SettingSection[] = [
id: 'environment-error-tracking',
title: 'Error tracking',
group: 'Products',
+ accessControl: {
+ resourceType: AccessControlResourceType.ErrorTracking,
+ minimumAccessLevel: AccessControlLevel.Viewer,
+ },
settings: [
{
id: 'banner',
@@ -464,6 +468,10 @@ export const SETTINGS_MAP: SettingSection[] = [
title: 'Error tracking',
group: 'Products',
hideFromNavigation: true,
+ accessControl: {
+ resourceType: AccessControlResourceType.ErrorTracking,
+ minimumAccessLevel: AccessControlLevel.Viewer,
+ },
settings: [
{
id: 'error-tracking-exception-autocapture',
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/AssignmentRules.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/AssignmentRules.tsx
index 35dd0f0b64cd..d8bf7be98295 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/AssignmentRules.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/assignment_rules/AssignmentRules.tsx
@@ -11,6 +11,7 @@ import {
AssigneeResolver,
} from '../../../components/Assignee/AssigneeDisplay'
import { assigneeSelectLogic } from '../../../components/Assignee/assigneeSelectLogic'
+import { errorTrackingEditAccessDisabledReason } from '../../../utils'
import { RuleList } from '../rules/RuleList'
import { ErrorTrackingAssignmentRule, ErrorTrackingRuleType } from '../rules/types'
import { AssignmentRuleModal } from './AssignmentRuleModal'
@@ -40,7 +41,12 @@ export function AssignmentRules(): JSX.Element {
pageKeyPrefix="assignment-rule"
onMount={onMount}
headerActions={
- <LemonButton type="secondary" size="small" onClick={() => openCodeOwnersModal()}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() => openCodeOwnersModal()}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? undefined}
+ >
Code owners
</LemonButton>
}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsx
index 953c3be68899..143825f264ca 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsx
@@ -11,6 +11,7 @@ import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
import { urls } from 'scenes/urls'
+import { errorTrackingEditAccessDisabledReason } from '../../../utils'
import { issueRateLimitConfigLogic } from './issueRateLimitConfigLogic'
import { BUCKET_OPTIONS } from './rateLimitConfigLogic'
import { RateLimitHistoryChart } from './RateLimitHistoryChart'
@@ -97,7 +98,10 @@ function ConfigColumn(): JSX.Element {
<LemonButton
type="primary"
htmlType="submit"
- disabledReason={!configFormChanged ? 'No changes to save' : undefined}
+ disabledReason={
+ errorTrackingEditAccessDisabledReason() ??
+ (!configFormChanged ? 'No changes to save' : undefined)
+ }
loading={isConfigFormSubmitting}
>
Save
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsx
index 10f12e956588..6fd946cec37c 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsx
@@ -10,6 +10,7 @@ import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonInput } from 'lib/lemon-ui/LemonInput'
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
+import { errorTrackingEditAccessDisabledReason } from '../../../utils'
import { BypassRules } from '../bypass_rules/BypassRules'
import { IssueRateLimitSettings } from './IssueRateLimitSettings'
import { BUCKET_OPTIONS, rateLimitConfigLogic } from './rateLimitConfigLogic'
@@ -113,7 +114,10 @@ function ProjectRateLimitSection(): JSX.Element {
<LemonButton
type="primary"
htmlType="submit"
- disabledReason={!configFormChanged ? 'No changes to save' : undefined}
+ disabledReason={
+ errorTrackingEditAccessDisabledReason() ??
+ (!configFormChanged ? 'No changes to save' : undefined)
+ }
loading={isConfigFormSubmitting}
>
Save
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleList.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleList.tsx
index abc95af7b1e9..82141ccb2b24 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleList.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleList.tsx
@@ -14,6 +14,7 @@ import { cn } from 'lib/utils/css-classes'
import { AnyPropertyFilter, FilterLogicalOperator } from '~/types'
+import { errorTrackingEditAccessDisabledReason } from '../../../utils'
import { rulesLogic } from './rulesLogic'
import { SortableRuleItem } from './SortableRuleItem'
import { ErrorTrackingRule, ErrorTrackingRuleType } from './types'
@@ -142,15 +143,30 @@ export function RuleList({
{headerActions}
{rules.length > 1 && (
<>
- <LemonButton type="secondary" size="small" onClick={startSelectingRules}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={startSelectingRules}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? undefined}
+ >
Select
</LemonButton>
- <LemonButton type="secondary" size="small" onClick={startReorderingRules}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={startReorderingRules}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? undefined}
+ >
Reorder
</LemonButton>
</>
)}
- <LemonButton type="primary" size="small" onClick={() => openModal()}>
+ <LemonButton
+ type="primary"
+ size="small"
+ onClick={() => openModal()}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? undefined}
+ >
Add rule
</LemonButton>
</>
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleModal.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleModal.tsx
index 27cf4d30a092..fedf0ad09dca 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleModal.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/RuleModal.tsx
@@ -9,6 +9,7 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { AnyPropertyFilter, FilterLogicalOperator } from '~/types'
+import { errorTrackingEditAccessDisabledReason } from '../../../utils'
import { DisabledRuleBanner } from './DisabledRuleBanner'
import { MatchResultBanner } from './MatchResultBanner'
@@ -51,7 +52,7 @@ export function RuleModal({
const isEditing = rule.id !== 'new'
const defaultSaveDisabled = !filtersOptional && !hasFilters ? 'Add at least one filter' : undefined
- const resolvedSaveDisabled = saveDisabledReason ?? defaultSaveDisabled
+ const resolvedSaveDisabled = errorTrackingEditAccessDisabledReason() ?? saveDisabledReason ?? defaultSaveDisabled
const [confirmingDelete, setConfirmingDelete] = useState(false)
const [confirmEnabled, setConfirmEnabled] = useState(false)
@@ -102,7 +103,8 @@ export function RuleModal({
size="small"
loading={deletingLoading}
disabledReason={
- confirmingDelete && !confirmEnabled ? 'Click again to confirm' : undefined
+ errorTrackingEditAccessDisabledReason() ??
+ (confirmingDelete && !confirmEnabled ? 'Click again to confirm' : undefined)
}
onClick={() => {
if (confirmingDelete && confirmEnabled) {
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/Rules.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/Rules.tsx
index a001d5613790..429f7c5e9b38 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/Rules.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/Rules.tsx
@@ -21,6 +21,7 @@ import {
AssigneeResolver,
} from '../../../components/Assignee/AssigneeDisplay'
import { AssigneeSelect } from '../../../components/Assignee/AssigneeSelect'
+import { errorTrackingEditAccessDisabledReason } from '../../../utils'
import { rulesLogic } from './rulesLogic'
import { ErrorTrackingAssignmentRule, ErrorTrackingRule, ErrorTrackingRuleType } from './types'
@@ -138,7 +139,10 @@ const ReorderRules = (): JSX.Element | null => {
size="small"
type="secondary"
onClick={startReorderingRules}
- disabledReason={localRules.length > 0 ? 'Finish editing all rules before reordering' : undefined}
+ disabledReason={
+ errorTrackingEditAccessDisabledReason() ??
+ (localRules.length > 0 ? 'Finish editing all rules before reordering' : undefined)
+ }
>
Reorder
</LemonButton>
@@ -179,7 +183,12 @@ export const AddRule = ({ disabledReason }: { disabledReason: string | undefined
return !hasNewRule && !isReorderingRules ? (
<div>
- <LemonButton type="primary" size="small" onClick={addRule} disabledReason={disabledReason}>
+ <LemonButton
+ type="primary"
+ size="small"
+ onClick={addRule}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? disabledReason}
+ >
Add rule
</LemonButton>
</div>
@@ -243,7 +252,12 @@ function Actions<T extends ErrorTrackingRule>({
</LemonButton>
</>
) : (
- <LemonButton size="small" icon={<IconPencil />} onClick={() => setRuleEditable(rule.id)} />
+ <LemonButton
+ size="small"
+ icon={<IconPencil />}
+ onClick={() => setRuleEditable(rule.id)}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? undefined}
+ />
)}
</div>
)
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/spike_detection/SpikeDetectionSettings.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/spike_detection/SpikeDetectionSettings.tsx
index 9c53d0023bea..73215c1c4952 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/spike_detection/SpikeDetectionSettings.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/spike_detection/SpikeDetectionSettings.tsx
@@ -9,7 +9,7 @@ import { LemonInput } from 'lib/lemon-ui/LemonInput'
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { settingsLogic } from 'scenes/settings/settingsLogic'
-import { ERROR_TRACKING_LOGIC_KEY } from '../../../utils'
+import { ERROR_TRACKING_LOGIC_KEY, errorTrackingEditAccessDisabledReason } from '../../../utils'
import { RecentSpikes } from './RecentSpikes'
import { spikeDetectionConfigLogic } from './spikeDetectionConfigLogic'
@@ -111,7 +111,10 @@ export function SpikeDetectionSettings(): JSX.Element {
<LemonButton
type="primary"
htmlType="submit"
- disabledReason={!configFormChanged ? 'No changes to save' : undefined}
+ disabledReason={
+ errorTrackingEditAccessDisabledReason() ??
+ (!configFormChanged ? 'No changes to save' : undefined)
+ }
loading={isConfigFormSubmitting}
>
Save
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/symbol_sets/SymbolSets.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/symbol_sets/SymbolSets.tsx
index 1b9855915b1a..ce80695b1022 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/symbol_sets/SymbolSets.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/symbol_sets/SymbolSets.tsx
@@ -21,6 +21,7 @@ import { humanFriendlyDetailedTime } from 'lib/utils/datetime'
import { pluralize } from 'lib/utils/strings'
import { ReleasePreviewPill } from 'products/error_tracking/frontend/components/ReleasesPreview/ReleasePreviewPill'
+import { errorTrackingEditAccessDisabledReason } from 'products/error_tracking/frontend/utils'
import { RESULTS_PER_PAGE, SymbolSetOrder, symbolSetLogic } from './symbolSetLogic'
@@ -79,6 +80,7 @@ export function SymbolSets(): JSX.Element {
size="small"
icon={<IconTrash />}
loading={deleteSymbolSetResponseLoading}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? undefined}
onClick={() =>
LemonDialog.open({
title: 'Delete symbol sets',
@@ -270,6 +272,7 @@ const SymbolSetTable = (): JSX.Element => {
size="xsmall"
tooltip="Delete symbol set"
icon={<IconTrash />}
+ disabledReason={errorTrackingEditAccessDisabledReason() ?? undefined}
onClick={() =>
LemonDialog.open({
title: 'Delete symbol set',
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx
index 9a835bb22e03..dab996d82bd1 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx
@@ -4,9 +4,11 @@ import posthog from 'posthog-js'
import { LemonBadge, LemonBanner, LemonButton, LemonTab, LemonTabs, Link, Spinner } from '@posthog/lemon-ui'
import api from 'lib/api'
+import { AccessDenied } from 'lib/components/AccessDenied'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { IconFeedback } from 'lib/lemon-ui/icons'
+import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene, SceneExport } from 'scenes/sceneTypes'
@@ -14,7 +16,7 @@ import { Settings } from 'scenes/settings/Settings'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
-import { CyclotronJobFiltersType } from '~/types'
+import { AccessControlLevel, AccessControlResourceType, CyclotronJobFiltersType } from '~/types'
import { IntegrationsMovedBanner } from '../../components/IntegrationsMovedBanner'
import { ErrorTrackingIssueFilteringTool } from '../../components/IssueFilteringTool'
@@ -53,6 +55,11 @@ export function ErrorTrackingScene(): JSX.Element {
const { setActiveTab } = useActions(errorTrackingSceneLogic)
const hasRecommendations = useFeatureFlag('ERROR_TRACKING_RECOMMENDATIONS')
const hasSourceMapsBanner = useFeatureFlag('ERROR_TRACKING_SOURCE_MAPS_BANNER')
+ // Same gate as the settings section: configuration endpoints require error tracking viewer access.
+ const configurationAccessDeniedReason = getAccessControlDisabledReason(
+ AccessControlResourceType.ErrorTracking,
+ AccessControlLevel.Viewer
+ )
useOnMountEffect(() => {
const utmSource = new URLSearchParams(window.location.search).get('utm_source')
@@ -103,7 +110,12 @@ export function ErrorTrackingScene(): JSX.Element {
{
key: 'configuration',
label: 'Configuration',
- content: (
+ disabledReason: configurationAccessDeniedReason ?? undefined,
+ content: configurationAccessDeniedReason ? (
+ // Deep links can activate the tab even though it's disabled, so the
+ // content must deny too — not just the tab button.
+ <AccessDenied reason={configurationAccessDeniedReason} />
+ ) : (
<>
<IntegrationsMovedBanner />
<Settings
diff --git a/products/error_tracking/frontend/utils.ts b/products/error_tracking/frontend/utils.ts
index 4404d9fa2433..2159c31ff8c0 100644
--- a/products/error_tracking/frontend/utils.ts
+++ b/products/error_tracking/frontend/utils.ts
@@ -5,10 +5,17 @@ import { MouseEvent } from 'react'
import { ErrorTrackingException } from 'lib/components/Errors/types'
import { Dayjs, dayjs } from 'lib/dayjs'
+import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { componentsToDayJs, dateStringToComponents, dateStringToDayJs, isStringDateRegex } from 'lib/utils/dateFilters'
import { Params } from 'scenes/sceneTypes'
import { DateRange, ErrorTrackingIssue } from '~/queries/schema/schema-general'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+/** Reason error tracking write actions are disabled, or null when the user has editor access. */
+export function errorTrackingEditAccessDisabledReason(): string | null {
+ return getAccessControlDisabledReason(AccessControlResourceType.ErrorTracking, AccessControlLevel.Editor)
+}
export const ERROR_TRACKING_LOGIC_KEY = 'errorTracking'
export const ERROR_TRACKING_LISTING_RESOLUTION = 20