: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(settings): align project secret API key limit (#98502)
Ben White23e61c1a2576
diff --git a/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.test.tsx b/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.test.tsxnew file mode 100644index 000000000000..382ef630e7e3--- /dev/null+++ b/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.test.tsx@@ -0,0 +1,75 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'++import { OrganizationMembershipLevel } from 'lib/constants'+import { teamLogic } from 'scenes/teamLogic'++import { ProjectSecretAPIKeyApi } from '~/generated/core/api.schemas'+import { initKeaTests } from '~/test/init'++import { ProjectSecretAPIKeys } from './ProjectSecretAPIKeys'+import { MAX_PROJECT_API_KEYS_PER_PROJECT, projectSecretAPIKeysLogic } from './projectSecretAPIKeysLogic'++const createKeys = (count: number): ProjectSecretAPIKeyApi[] =>+ Array.from({ length: count }, (_, index) => ({+ id: String(index),+ label: `Key ${index}`,+ value: '',+ mask_value: null,+ created_at: '2026-01-01T00:00:00Z',+ created_by: {+ id: 1,+ uuid: 'test-user',+ first_name: 'Test',+ email: '[email protected]',+ hedgehog_config: null,+ },+ last_used_at: null,+ last_rolled_at: null,+ scopes: ['endpoint:read'],+ }))++describe('<ProjectSecretAPIKeys />', () => {+ const logic = projectSecretAPIKeysLogic()++ beforeEach(() => {+ initKeaTests()+ teamLogic.mount()+ teamLogic.actions.loadCurrentTeamSuccess({+ ...MOCK_DEFAULT_TEAM,+ effective_membership_level: OrganizationMembershipLevel.Admin,+ })+ logic.mount()+ })++ afterEach(() => {+ cleanup()+ logic.unmount()+ })++ it.each([+ {+ description: 'below the backend limit',+ keyCount: MAX_PROJECT_API_KEYS_PER_PROJECT - 1,+ expectedDisabled: false,+ },+ {+ description: 'at the backend limit',+ keyCount: MAX_PROJECT_API_KEYS_PER_PROJECT,+ expectedDisabled: true,+ },+ ])('sets creation availability $description', ({ keyCount, expectedDisabled }) => {+ logic.actions.loadKeysSuccess(createKeys(keyCount))+ render(<ProjectSecretAPIKeys />)++ const button = screen.getByText('Create project secret API key').closest('button')+ if (expectedDisabled) {+ expect(button).toHaveAttribute('aria-disabled', 'true')+ } else {+ expect(button).not.toHaveAttribute('aria-disabled', 'true')+ }+ })+})diff --git a/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsx b/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsxindex 0691cd2152aa..99340fb53217 100644--- a/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsx+++ b/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsx@@ -29,7 +29,7 @@ export type EditingProjectKeyFormValues = ProjectSecretAPIKeyRequest & {preset?: string}-export const MAX_PROJECT_API_KEYS_PER_PROJECT = 10+export const MAX_PROJECT_API_KEYS_PER_PROJECT = 50// llm_gateway powers the new AI gateway here, so label it "AI gateway" (PAKs keep "LLM gateway").const PROJECT_SECRET_SCOPE_OBJECT_NAMES: Record<string, string> = {