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(surveys): skip appearance CSS validation for API surveys (#59009)

Ben Lea3e9621085c2e
diff --git a/frontend/src/scenes/surveys/utils.test.ts b/frontend/src/scenes/surveys/utils.test.ts
index 5075885fdb31..63b8c53c15c9 100644
--- a/frontend/src/scenes/surveys/utils.test.ts
+++ b/frontend/src/scenes/surveys/utils.test.ts
@@ -38,6 +38,7 @@ import {
sanitizeSurveyDisplayConditions,
splitChoicesOnPaste,
validateCSSProperty,
+ validateSurveyAppearance,
} from './utils'
jest.mock('lib/utils/getAppContext', () => ({
@@ -159,6 +160,28 @@ describe('survey utils', () => {
})
})
+ describe('validateSurveyAppearance', () => {
+ const invalidAppearance: SurveyAppearance = {
+ backgroundColor: 'not-a-color',
+ borderColor: 'also-not-a-color',
+ maxWidth: 'definitely-not-a-width',
+ }
+
+ it('skips all appearance validation for API surveys', () => {
+ // API surveys are rendered by the customer, so PostHog's appearance CSS is not applied
+ // and the Customization section is hidden in the editor — flagging errors here would
+ // route submitSurveyFailure to a non-existent section and silently block saves.
+ expect(validateSurveyAppearance(invalidAppearance, false, SurveyType.API)).toEqual({})
+ })
+
+ it('validates appearance CSS for Popover surveys', () => {
+ const result = validateSurveyAppearance(invalidAppearance, false, SurveyType.Popover)
+ expect(result.backgroundColor).toBe('not-a-color is not a valid property for background-color.')
+ expect(result.borderColor).toBe('also-not-a-color is not a valid property for border-color.')
+ expect(result.maxWidth).toBe('definitely-not-a-width is not a valid property for width.')
+ })
+ })
+
describe('getSurveyNotificationFilters', () => {
it('builds survey-specific notification filters', () => {
expect(getSurveyNotificationFilters('survey-123')).toEqual({
diff --git a/frontend/src/scenes/surveys/utils.ts b/frontend/src/scenes/surveys/utils.ts
index 3af79c32b3d5..cc33131afe71 100644
--- a/frontend/src/scenes/surveys/utils.ts
+++ b/frontend/src/scenes/surveys/utils.ts
@@ -65,6 +65,13 @@ export function validateSurveyAppearance(
hasRatingQuestions: boolean,
surveyType: SurveyType
): DeepPartialMap<SurveyAppearance, ValidationErrorType> {
+ // API surveys are rendered by the customer, so PostHog's appearance CSS is not applied.
+ // The Customization section is also hidden in the editor for API surveys (SurveyEdit.tsx),
+ // so flagging appearance errors would route submitSurveyFailure to a non-existent section
+ // and silently block saves.
+ if (surveyType === SurveyType.API) {
+ return {}
+ }
return {
backgroundColor: validateCSSProperty('background-color', appearance.backgroundColor),
borderColor: validateCSSProperty('border-color', appearance.borderColor),