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(warehouse-sources): drop webhook deliveries instead of rejecting them when no credential is set (#100361)

Harley Alexander012b1a8e7606
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 8a6fdb8d36d7..a628590dfa53 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -6552,6 +6552,8 @@ export interface WebhookInfo {
webhook_url?: string
schema_mapping?: Record<string, string>
inputs?: Record<string, WebhookInputValue>
+ // Required webhook field names with no value yet. Deliveries are dropped while any is missing.
+ missing_inputs?: string[]
external_status?: WebhookExternalStatus | null
// Desired provider events not yet on the webhook (manual setup, or created before a new table).
missing_events?: string[]
diff --git a/nodejs/src/cdp/consumers/cdp-dwh-source-webhooks.consumer.test.ts b/nodejs/src/cdp/consumers/cdp-dwh-source-webhooks.consumer.test.ts
index 12b608f0c352..7c062a7a42ab 100644
--- a/nodejs/src/cdp/consumers/cdp-dwh-source-webhooks.consumer.test.ts
+++ b/nodejs/src/cdp/consumers/cdp-dwh-source-webhooks.consumer.test.ts
@@ -73,6 +73,16 @@ if (request.method != 'POST') {
}
if (not inputs.bypass_signature_check) {
+ if (empty(inputs.signing_secret)) {
+ return {
+ 'httpResponse': {
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
+ }
+ }
+
let body := request.stringBody
let signatureHeader := request.headers['stripe-signature']
@@ -281,6 +291,12 @@ describe('DWH source webhooks', () => {
await api['cdpSourceWebhooksConsumer']['promiseScheduler'].waitForAllSettled()
}
+ const getMetricNames = (): string[] => {
+ return mockProducerObserver
+ .getProducedKafkaMessagesForTopic('clickhouse_app_metrics2_test')
+ .map((message) => message.value.metric_name) as string[]
+ }
+
it('should return 404 for non-existent webhook ID', async () => {
const res = await doDwhPostRequest({ webhookId: 'non-existent-id' })
expect(res.status).toEqual(404)
@@ -367,6 +383,37 @@ describe('DWH source webhooks', () => {
expect(kafkaMessages[0].key).toEqual(`${team.id}:${chargeSchemaId}`)
})
+ it('should drop the delivery instead of rejecting it when no signing secret is set', async () => {
+ const unconfiguredFunction = await insertHogFunction(hub.postgres, team.id, {
+ type: 'warehouse_source_webhook',
+ template_id: stripeTemplateId,
+ bytecode: [],
+ inputs: {
+ ...(await compileInputs(stripeTemplateForInputs, {
+ signing_secret: '',
+ bypass_signature_check: false,
+ })),
+ schema_mapping: { value: schemaMapping },
+ source_id: { value: 'test-source-id' },
+ source_type: { value: 'Stripe' },
+ },
+ })
+
+ const res = await doDwhPostRequest({
+ webhookId: unconfiguredFunction.id,
+ body: { type: 'charge.succeeded', data: { object: { id: 'ch_1', object: 'charge' } } },
+ })
+
+ // A 4xx here makes the provider retry for hours over a gap only the customer can close.
+ expect(res.status).toEqual(200)
+ expect(res.text).toEqual('Signing secret not configured, delivery dropped')
+ expect(getDwhKafkaMessages()).toHaveLength(0)
+
+ await waitForBackgroundTasks()
+
+ expect(getMetricNames()).toContain('missing_credential')
+ })
+
it('should return 200 and skip when object type is not in schema_mapping', async () => {
const webhookReq = createStripeWebhookRequest(signingSecret, {
type: 'payment_intent.created',
diff --git a/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts b/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts
index a9d6a08f8c1b..22d92a9c2e05 100644
--- a/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts
+++ b/nodejs/src/cdp/consumers/cdp-source-webhooks.consumer.ts
@@ -73,6 +73,24 @@ export const getCustomHttpResponse = (
return null
}
+// Metric names a webhook template may raise from its own code. A template signals one with
+// `appMetric`, beside `httpResponse`. This lets a template answer 200 to a delivery it cannot
+// process, and still record the failure against the function.
+const TEMPLATE_APP_METRIC_NAMES = ['missing_credential'] as const satisfies readonly MinimalAppMetric['metric_name'][]
+
+export const getCustomAppMetricName = (
+ result: CyclotronJobInvocationResult<CyclotronJobInvocationHogFunction>
+): MinimalAppMetric['metric_name'] | null => {
+ if (typeof result.execResult === 'object' && result.execResult && 'appMetric' in result.execResult) {
+ const appMetric = result.execResult.appMetric
+ if (typeof appMetric === 'string' && (TEMPLATE_APP_METRIC_NAMES as readonly string[]).includes(appMetric)) {
+ return appMetric as MinimalAppMetric['metric_name']
+ }
+ }
+
+ return null
+}
+
export class SourceWebhookError extends Error {
status: number
@@ -396,8 +414,22 @@ export class CdpSourceWebhooksConsumer extends CdpConsumerBase<PluginsServerConf
}
const customHttpResponse = getCustomHttpResponse(result)
+ const customAppMetricName = getCustomAppMetricName(result)
+
+ if (customAppMetricName) {
+ result.metrics.push({
+ team_id: hogFunction.team_id,
+ app_source_id: hogFunction.id,
+ metric_kind: 'failure',
+ metric_name: customAppMetricName,
+ count: 1,
+ })
+ }
+
if (customHttpResponse) {
- const level = customHttpResponse.status >= 400 ? 'warn' : 'info'
+ // A template that drops a delivery answers 200, to stop the provider retrying.
+ // The status alone therefore no longer shows whether we processed the delivery.
+ const level = customHttpResponse.status >= 400 || customAppMetricName ? 'warn' : 'info'
if (level === 'warn') {
const bodyStr =
typeof customHttpResponse.body === 'string'
diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.ts
index 1954d850ee9a..322d580f05cc 100644
--- a/nodejs/src/cdp/types.ts
+++ b/nodejs/src/cdp/types.ts
@@ -241,6 +241,7 @@ export type MinimalAppMetric = {
| 'masked'
| 'filtering_failed'
| 'inputs_failed'
+ | 'missing_credential'
| 'missing_addon'
| 'fetch'
| 'billable_invocation'
diff --git a/nodejs/tests/fixtures/hog-bytecode/4010d561e90ccc81d50db36c39fb5b0fd034159e17e65f155db3386fb855a80b.json b/nodejs/tests/fixtures/hog-bytecode/4010d561e90ccc81d50db36c39fb5b0fd034159e17e65f155db3386fb855a80b.json
new file mode 100644
index 000000000000..4384655c7510
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/4010d561e90ccc81d50db36c39fb5b0fd034159e17e65f155db3386fb855a80b.json
@@ -0,0 +1 @@
+["_H",1,32,"POST",32,"method",32,"request",1,2,12,40,15,32,"httpResponse",32,"status",33,405,32,"body",32,"Method not allowed",42,2,42,1,38,32,"bypass_signature_check",32,"inputs",1,2,5,40,288,32,"signing_secret",32,"inputs",1,2,2,"empty",1,40,19,32,"httpResponse",32,"status",33,200,32,"body",32,"Signing secret not configured, delivery dropped",42,2,32,"appMetric",32,"missing_credential",42,2,38,32,"stringBody",32,"request",1,2,32,"headers",32,"request",1,2,32,"stripe-signature",45,36,1,2,"empty",1,40,15,32,"httpResponse",32,"status",33,400,32,"body",32,"Missing signature",42,2,42,1,38,32,",",36,1,2,"splitByString",2,31,31,36,2,36,5,2,"keys",1,36,5,2,"values",1,33,1,36,7,2,"length",1,31,31,36,9,36,8,16,40,97,36,6,36,8,45,37,10,36,7,36,8,45,37,11,36,11,2,"trim",1,32,"t=%",36,12,17,40,27,32,"=",36,12,33,2,2,"splitByString",3,33,2,36,13,2,"length",1,11,40,7,36,13,33,2,45,37,3,35,32,"v1=%",36,12,17,40,27,32,"=",36,12,33,2,2,"splitByString",3,33,2,36,13,2,"length",1,11,40,7,36,13,33,2,45,37,4,35,35,36,8,33,1,6,37,8,39,-104,35,35,35,35,35,35,35,36,3,2,"empty",1,36,4,2,"empty",1,4,2,40,15,32,"httpResponse",32,"status",33,400,32,"body",32,"Could not parse signature",42,2,42,1,38,36,3,32,".",36,0,2,"concat",3,32,"signing_secret",32,"inputs",1,2,36,5,43,2,2,"sha256HmacChainHex",1,36,4,36,6,12,40,15,32,"httpResponse",32,"status",33,400,32,"body",32,"Bad signature",42,2,42,1,38,35,35,35,35,35,35,35,32,"data",32,"body",32,"request",1,3,32,"object",48,32,"object",48,36,0,2,"empty",1,40,15,32,"httpResponse",32,"status",33,200,32,"body",32,"No object type found, skipping",42,2,42,1,38,32,"schema_mapping",32,"inputs",1,2,36,0,48,36,1,2,"empty",1,40,22,32,"httpResponse",32,"status",33,200,32,"body",32,"No schema mapping for object type: ",36,0,32,", skipping",2,"concat",3,42,2,42,1,38,32,"body",32,"request",1,2,36,1,2,"produceToWarehouseWebhooks",2,35,35,35]
diff --git a/products/data_warehouse/frontend/scenes/SourceScene/tabs/WebhookTab.tsx b/products/data_warehouse/frontend/scenes/SourceScene/tabs/WebhookTab.tsx
index 6de3a36ccb14..01daf8ce332f 100644
--- a/products/data_warehouse/frontend/scenes/SourceScene/tabs/WebhookTab.tsx
+++ b/products/data_warehouse/frontend/scenes/SourceScene/tabs/WebhookTab.tsx
@@ -26,7 +26,7 @@ import {
} from '../../../shared/components/forms/WebhookSetupForm'
import type { WebhookCreateResult } from '../../../shared/components/forms/WebhookSetupForm'
import { WebhookLogsSection } from './WebhookLogsSection'
-import { WEBHOOK_SECTIONS, WebhookSection, webhookTabLogic } from './webhookTabLogic'
+import { MissingWebhookCredential, WEBHOOK_SECTIONS, WebhookSection, webhookTabLogic } from './webhookTabLogic'
const SECTION_LABELS: Record<WebhookSection, string> = {
overview: 'Overview',
@@ -34,12 +34,12 @@ const SECTION_LABELS: Record<WebhookSection, string> = {
activity: 'Activity',
}
-const WEBHOOK_METRIC_KEYS = ['succeeded', 'failed'] as const
+const WEBHOOK_METRIC_KEYS = ['succeeded', 'failed', 'missing_credential'] as const
const WEBHOOK_METRICS_INFO: Record<string, { name: string; description: string; color: string }> = {
succeeded: {
name: 'Received',
- description: 'Total number of webhook events received and processed successfully',
+ description: 'Total number of webhook events received and answered, including any that were dropped',
color: getColorVar('success'),
},
failed: {
@@ -47,6 +47,11 @@ const WEBHOOK_METRICS_INFO: Record<string, { name: string; description: string;
description: 'Total number of webhook events that had errors during processing',
color: getColorVar('danger'),
},
+ missing_credential: {
+ name: 'Dropped',
+ description: 'Total number of webhook events dropped because this webhook is missing a required credential',
+ color: getColorVar('warning'),
+ },
}
export function WebhookTab({ id }: { id: string }): JSX.Element {
@@ -63,6 +68,7 @@ export function WebhookTab({ id }: { id: string }): JSX.Element {
canDeleteWebhook,
webhookDeleting,
currentSection,
+ missingCredentials,
} = useValues(webhookTabLogic({ id }))
const { createWebhook, loadWebhookInfo, deleteWebhook, setCurrentSection } = useActions(webhookTabLogic({ id }))
@@ -128,6 +134,13 @@ export function WebhookTab({ id }: { id: string }): JSX.Element {
externalStateLabel={externalStateLabel}
onRefresh={loadWebhookInfo}
/>
+ {missingCredentials.length > 0 && (
+ <WebhookMissingCredentialsSection
+ missingCredentials={missingCredentials}
+ sourceName={sourceConfig?.label ?? source?.source_type ?? 'source'}
+ onGoToConfiguration={() => setCurrentSection('configuration')}
+ />
+ )}
{externalMissing && (
<WebhookRecreateSection
id={id}
@@ -335,6 +348,34 @@ function WebhookRecreateSection({
)
}
+function WebhookMissingCredentialsSection({
+ missingCredentials,
+ sourceName,
+ onGoToConfiguration,
+}: {
+ missingCredentials: MissingWebhookCredential[]
+ sourceName: string
+ onGoToConfiguration: () => void
+}): JSX.Element {
+ const fieldLabels = missingCredentials.map((credential) => credential.label).join(', ')
+
+ return (
+ <LemonBanner
+ type="warning"
+ action={{
+ children: 'Add it now',
+ onClick: onGoToConfiguration,
+ }}
+ >
+ <p className="mb-0">
+ This webhook is missing the {fieldLabels}, so we cannot check that a delivery really came from{' '}
+ {sourceName}. Until you add it, we accept every delivery and drop it, and no data reaches your tables.
+ Find it in your {sourceName} dashboard.
+ </p>
+ </LemonBanner>
+ )
+}
+
function WebhookMissingEventsSection({
missingEvents,
sourceName,
diff --git a/products/data_warehouse/frontend/scenes/SourceScene/tabs/webhookTabLogic.ts b/products/data_warehouse/frontend/scenes/SourceScene/tabs/webhookTabLogic.ts
index 0a84fafe8ae5..6bdc2853f234 100644
--- a/products/data_warehouse/frontend/scenes/SourceScene/tabs/webhookTabLogic.ts
+++ b/products/data_warehouse/frontend/scenes/SourceScene/tabs/webhookTabLogic.ts
@@ -24,6 +24,13 @@ export const WEBHOOK_SECTIONS = ['overview', 'configuration', 'activity'] as con
export type WebhookSection = (typeof WEBHOOK_SECTIONS)[number]
export const DEFAULT_WEBHOOK_SECTION: WebhookSection = 'overview'
+/** A required webhook credential with no value yet. `label` falls back to the input name for a
+ * credential the source does not put on its setup form. */
+export interface MissingWebhookCredential {
+ name: string
+ label: string
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface webhookTabLogicValues {
canDeleteWebhook: boolean
@@ -44,6 +51,7 @@ export interface webhookTabLogicValues {
objectType: string
tableName: string
}[]
+ missingCredentials: MissingWebhookCredential[]
showWebhookFieldInputsErrors: boolean
source: ExternalDataSource | null
sourceConfig: SourceConfigResponseApi | null
@@ -146,7 +154,14 @@ export interface webhookTabLogicMeta {
__keaTypeGenInternalSelectorTypes: {
source: (arg: ExternalDataSource | null) => ExternalDataSource | null
sourceConfig: (arg: SourceConfigResponseApi | null) => SourceConfigResponseApi | null
- internalStateLabel: (webhookInfo: WebhookInfo | null) => {
+ missingCredentials: (
+ webhookInfo: WebhookInfo | null,
+ sourceConfig: SourceConfigResponseApi | null
+ ) => MissingWebhookCredential[]
+ internalStateLabel: (
+ webhookInfo: WebhookInfo | null,
+ missingCredentials: MissingWebhookCredential[]
+ ) => {
label: string
tagType: 'danger' | 'default' | 'success' | 'warning'
}
@@ -247,11 +262,34 @@ export const webhookTabLogic = kea<webhookTabLogicType>([
],
(sourceFieldConfig: SourceConfigResponseApi | null): SourceConfigResponseApi | null => sourceFieldConfig,
],
+ missingCredentials: [
+ (s) => [s.webhookInfo, s.sourceConfig],
+ // The server decides what is missing, so every name it returns reaches the tab. Keying
+ // off the declared fields instead would drop a credential the user never types, and the
+ // tab would stay healthy with no banner while every delivery is dropped.
+ (
+ webhookInfo: WebhookInfo | null,
+ sourceConfig: SourceConfigResponseApi | null
+ ): MissingWebhookCredential[] => {
+ const fields = sourceConfig?.webhookFields ?? []
+ return (webhookInfo?.missing_inputs ?? []).map((name) => ({
+ name,
+ label: fields.find((field) => field.name === name)?.label ?? name,
+ }))
+ },
+ ],
internalStateLabel: [
- (s) => [s.webhookInfo],
+ (s) => [s.webhookInfo, s.missingCredentials],
(
- webhookInfo: WebhookInfo | null
+ webhookInfo: WebhookInfo | null,
+ missingCredentials: MissingWebhookCredential[]
): { label: string; tagType: 'success' | 'warning' | 'danger' | 'default' } => {
+ // The hog watcher never sees this fault, because a dropped delivery is a healthy
+ // run. Without this branch the tab reports "Healthy" while no data arrives.
+ if (missingCredentials.length > 0) {
+ return { label: 'Needs setup', tagType: 'warning' }
+ }
+
const state = webhookInfo?.hog_function?.status?.state
switch (state) {
case 1:
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py b/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py
index a6c1ae144803..537460524631 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py
@@ -131,6 +131,11 @@ class WebhookInfoResponseSerializer(serializers.Serializer):
child=serializers.CharField(),
help_text="Desired provider events not yet on the webhook (manual setup, or created before a new table).",
)
+ missing_inputs = serializers.ListField(
+ required=False,
+ child=serializers.CharField(),
+ help_text="Required webhook field names with no value yet. Deliveries are dropped while any is missing.",
+ )
class WebhookInfoBlockedResponseSerializer(serializers.Serializer):
@@ -412,6 +417,7 @@ class ExternalDataSourceWebhookSetupMixin(base.ExternalDataSourceViewSetBase):
"inputs": webhook_inputs,
"external_status": dataclasses.asdict(external_status) if external_status else None,
"missing_events": missing_events,
+ "missing_inputs": source.missing_webhook_inputs(all_inputs),
}
).data,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/tests/test_attentive_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/tests/test_attentive_webhook_template.py
index 33e7faa8b279..315a9d9bd2ef 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/tests/test_attentive_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/tests/test_attentive_webhook_template.py
@@ -108,7 +108,7 @@ class TestAttentiveWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
)
assert res.result == {"httpResponse": {"status": 400, "body": "Missing signature"}}
- def test_missing_signing_secret_returns_400(self):
+ def test_missing_signing_secret_drops_delivery(self):
globals = self._make_signed_request("secret")
res = self.run_function(
{
@@ -118,7 +118,10 @@ class TestAttentiveWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
},
globals=globals,
)
- assert res.result == {"httpResponse": {"status": 400, "body": "Signing secret not configured"}}
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
def test_bypass_signature_check(self):
body = {"type": "email.opened", "timestamp": 1632945178104}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/webhook_template.py
index 9a2ca1846bf2..16116d9fa0fe 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/attentive/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly_webhook_template.py
index 60c2e521e10c..fd99f906b382 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly_webhook_template.py
@@ -128,12 +128,15 @@ class TestCalendlyWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
("empty_string", ""),
]
)
- def test_unconfigured_signing_key_rejects_instead_of_accepting_anything(self, _name, signing_secret):
+ def test_unconfigured_signing_key_drops_delivery(self, _name, signing_secret):
res = self.run_function(
self._inputs(signing_secret=signing_secret), globals=self._signed_request(secret="anything")
)
- assert res.result == {"httpResponse": {"status": 400, "body": "Signing secret not configured"}}
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
self.mock_produce_to_warehouse_webhooks.assert_not_called()
@parameterized.expand(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/webhook_template.py
index 04e6d64beb56..e2e76019f527 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/webhook_template.py
index 7f5be8147cdc..6d8d0bda45f7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chatwoot/webhook_template.py
@@ -27,9 +27,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.py
index 63fb9df018a0..ad1afac31d66 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.py
@@ -553,6 +553,15 @@ class ExternalWebhookInfo:
error: str | None = None
+def _serialized_input_has_value(serialized: dict[str, Any] | None) -> bool:
+ # A set secret is redacted to `{"secret": True}`, so the marker is the only proof it has a value.
+ if not serialized:
+ return False
+ if serialized.get("secret"):
+ return True
+ return serialized.get("value") not in (None, "")
+
+
class WebhookSource(_BaseSource[ConfigType], Generic[ConfigType]):
"""Base class for sources that support webhook based imports."""
@@ -593,6 +602,18 @@ class WebhookSource(_BaseSource[ConfigType], Generic[ConfigType]):
"""
return None
+ def missing_webhook_inputs(self, inputs: dict[str, Any]) -> list[str]:
+ """Names of required ``webhookFields`` the hog function has no value for, from its serialized inputs.
+
+ While one is missing the webhook accepts and drops every delivery. Override where the
+ provider stores the credential under another input, so a configured webhook is not reported.
+ """
+ return [
+ field.name
+ for field in (self.get_source_config.webhookFields or [])
+ if getattr(field, "required", False) and not _serialized_input_has_value(inputs.get(field.name))
+ ]
+
def get_desired_webhook_events(self, config: ConfigType, eligible_schema_names: list[str]) -> list[str] | None:
"""Events the webhook should subscribe to. ``None`` when the source has no
provider-side subscription to drift (e.g. Slack); such sources skip reconciliation."""
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/tests/test_customer_io_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/tests/test_customer_io_webhook_template.py
index bb411a17dbf6..782d8e89a925 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/tests/test_customer_io_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/tests/test_customer_io_webhook_template.py
@@ -173,7 +173,7 @@ class TestCustomerIOWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
("empty_string", ""),
]
)
- def test_missing_signing_secret_returns_400(self, _name, signing_secret):
+ def test_missing_signing_secret_drops_delivery(self, _name, signing_secret):
globals = {
"request": {
"method": "POST",
@@ -191,7 +191,10 @@ class TestCustomerIOWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
},
globals=globals,
)
- assert res.result == {"httpResponse": {"status": 400, "body": "Signing secret not configured"}}
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
@parameterized.expand(
[
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/webhook_template.py
index ddae94e7818f..124388f580ca 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/customer_io/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/featurebase/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/featurebase/webhook_template.py
index 7ad584080777..4a9731c811d5 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/featurebase/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/featurebase/webhook_template.py
@@ -28,9 +28,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/tests/test_fourthwall_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/tests/test_fourthwall_webhook_template.py
index 1afca8425fba..fb36f951df2f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/tests/test_fourthwall_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/tests/test_fourthwall_webhook_template.py
@@ -110,15 +110,29 @@ class TestFourthwallWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
assert res.result == {"httpResponse": {"status": 400, "body": "Bad signature"}}
self.mock_produce_to_warehouse_webhooks.assert_not_called()
+ def test_missing_signing_secret_drops_delivery(self):
+ body = self._event()
+ globals = {
+ "request": {
+ "method": "POST",
+ "headers": {"x-fourthwall-hmac-sha256": "x"},
+ "body": body,
+ "stringBody": json.dumps(body),
+ "query": {},
+ }
+ }
+
+ res = self.run_function(self._inputs(signing_secret=""), globals=globals)
+
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
+ self.mock_produce_to_warehouse_webhooks.assert_not_called()
+
@parameterized.expand(
[
("missing_signature", {}, {"signing_secret": SIGNING_SECRET}, "Missing signature"),
- (
- "no_secret_configured",
- {"x-fourthwall-hmac-sha256": "x"},
- {"signing_secret": ""},
- "Signing secret not configured",
- ),
]
)
def test_unverifiable_delivery_is_rejected(self, _name, headers, input_overrides, expected_body):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/webhook_template.py
index 27da01dd2da3..4b0752a8c5a0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fourthwall/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/webhook_template.py
index 3211a7c2ff3d..9695e48df0fc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitea/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/github/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/github/webhook_template.py
index 5450851889e7..6353f80dbc28 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/github/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/github/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/instantly/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/instantly/webhook_template.py
index 58d1f95c586f..e6917844f71e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/instantly/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/instantly/webhook_template.py
@@ -28,9 +28,10 @@ if (not inputs.bypass_secret_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Webhook secret not configured',
- }
+ 'status': 200,
+ 'body': 'Webhook secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lemon_squeezy/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lemon_squeezy/webhook_template.py
index 53f40196e3b2..322b477f2a98 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lemon_squeezy/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lemon_squeezy/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/webhook_template.py
index be6914098c80..80fb692e8ab1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/webhook_template.py
@@ -32,9 +32,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/tests/test_mailgun_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/tests/test_mailgun_webhook_template.py
index 333ece2dcf17..d204b8e7055f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/tests/test_mailgun_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/tests/test_mailgun_webhook_template.py
@@ -114,12 +114,15 @@ class TestMailgunWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
("empty_string", ""),
]
)
- def test_missing_signing_secret_returns_400(self, _name, signing_secret):
+ def test_missing_signing_secret_drops_delivery(self, _name, signing_secret):
globals = self._make_signed_request()
res = self.run_function(self._inputs(signing_secret=signing_secret), globals=globals)
- assert res.result == {"httpResponse": {"status": 400, "body": "Signing secret not configured"}}
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
self.mock_produce_to_warehouse_webhooks.assert_not_called()
@parameterized.expand(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/webhook_template.py
index 1c1df18120bf..870d0c722382 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailgun/webhook_template.py
@@ -26,9 +26,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/tests/test_mailjet_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/tests/test_mailjet_webhook_template.py
index 6b921964cfdc..af1aac815e3c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/tests/test_mailjet_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/tests/test_mailjet_webhook_template.py
@@ -116,11 +116,26 @@ class TestMailjetWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
assert res.result["httpResponse"]["status"] == 200
self.mock_produce_to_warehouse_webhooks.assert_not_called()
+ def test_missing_authorization_header_value_drops_delivery(self):
+ # PostHog registers the callback before the header value is stored, so a delivery can
+ # arrive with nothing to check it against. A 4xx would only start Mailjet's retry loop.
+ globals = self._request(self._event())
+
+ res = self.run_function(self._inputs(authorization_header=""), globals=globals)
+
+ assert res.result == {
+ "httpResponse": {
+ "status": 200,
+ "body": "Authorization header value not configured, delivery dropped",
+ },
+ "appMetric": "missing_credential",
+ }
+ self.mock_produce_to_warehouse_webhooks.assert_not_called()
+
@parameterized.expand(
[
("wrong_credentials", "Basic " + base64.b64encode(b"posthog:wrong").decode(), {}, 401),
("missing_header", None, {}, 401),
- ("no_expected_header_configured", AUTHORIZATION_HEADER, {"authorization_header": ""}, 400),
]
)
def test_unauthenticated_delivery_is_rejected(self, _name, header, input_overrides, expected_status):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/webhook_template.py
index aec319c32350..6a5490296b35 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailjet/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_authorization_check) {
if (empty(inputs.authorization_header)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Authorization header value not configured',
- }
+ 'status': 200,
+ 'body': 'Authorization header value not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_webhook_template.py
index 9fe9cb759b09..df1e59aecb07 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_webhook_template.py
@@ -87,12 +87,27 @@ class TestPipedriveWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
self.mock_produce_to_warehouse_webhooks.assert_called_once_with(globals["request"]["body"], expected_schema_id)
+ def test_missing_http_auth_credentials_drops_delivery(self) -> None:
+ # PostHog creates the subscription before the credentials are stored, so a delivery can
+ # arrive with nothing to check it against. A 4xx would only start Pipedrive's retry loop.
+ globals = self._request(self._payload(), headers={"authorization": "Basic x"})
+
+ res = self.run_function(self._inputs(http_auth_password=""), globals=globals)
+
+ assert res.result == {
+ "httpResponse": {
+ "status": 200,
+ "body": "HTTP auth credentials not configured, delivery dropped",
+ },
+ "appMetric": "missing_credential",
+ }
+ self.mock_produce_to_warehouse_webhooks.assert_not_called()
+
@parameterized.expand(
[
("wrong_password", {"authorization": _basic(AUTH_USER, "not-the-password")}, {}, 401),
("wrong_user", {"authorization": _basic("someone-else", AUTH_PASSWORD)}, {}, 401),
("missing_header", {}, {}, 401),
- ("no_credentials_configured", {"authorization": "Basic x"}, {"http_auth_password": ""}, 400),
]
)
def test_unverified_delivery_is_rejected(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/webhook_template.py
index d6b6fc50ac8b..15a184c99960 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_auth_check) {
if (empty(inputs.http_auth_user) or empty(inputs.http_auth_password)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'HTTP auth credentials not configured',
- }
+ 'status': 200,
+ 'body': 'HTTP auth credentials not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/tests/test_postmark_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/tests/test_postmark_webhook_template.py
index 640af994ae47..8f4d3449709d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/tests/test_postmark_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/tests/test_postmark_webhook_template.py
@@ -91,16 +91,21 @@ class TestPostmarkWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
assert res.result["httpResponse"]["status"] == 200
self.mock_produce_to_warehouse_webhooks.assert_not_called()
+ def test_missing_webhook_secret_drops_delivery(self):
+ globals = self._request(self._bounce(), headers={WEBHOOK_SECRET_HEADER: WEBHOOK_SECRET})
+
+ res = self.run_function(self._inputs(signing_secret=""), globals=globals)
+
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Webhook secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
+ self.mock_produce_to_warehouse_webhooks.assert_not_called()
+
@parameterized.expand(
[
("wrong_secret", {WEBHOOK_SECRET_HEADER: "not-the-secret"}, {}, "Bad webhook secret"),
("missing_header", {}, {}, "Bad webhook secret"),
- (
- "secret_not_configured",
- {WEBHOOK_SECRET_HEADER: WEBHOOK_SECRET},
- {"signing_secret": ""},
- "Webhook secret not configured",
- ),
]
)
def test_unauthenticated_deliveries_are_rejected(self, _name, headers, input_overrides, expected_body):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/webhook_template.py
index 1590bbe9917d..5bdb3ec6e067 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postmark/webhook_template.py
@@ -28,9 +28,10 @@ if (request.method != 'POST') {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Webhook secret not configured',
- }
+ 'status': 200,
+ 'body': 'Webhook secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/webhook_template.py
index a3bf5c0d3aeb..67ee265a197a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_authorization_check) {
if (empty(inputs.authorization_header)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Authorization header value not configured',
- }
+ 'status': 200,
+ 'body': 'Authorization header value not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/slack/tests/test_slack_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/slack/tests/test_slack_webhook_template.py
index 8b54a8c7a8f9..be94748ea16e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/slack/tests/test_slack_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/slack/tests/test_slack_webhook_template.py
@@ -107,7 +107,7 @@ class TestSlackWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
("empty_string", ""),
]
)
- def test_missing_signing_secret_returns_400(self, _name, signing_secret):
+ def test_missing_signing_secret_drops_delivery(self, _name, signing_secret):
globals = {
"request": {
"method": "POST",
@@ -121,7 +121,10 @@ class TestSlackWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
{"signing_secret": signing_secret, "bypass_signature_check": False},
globals=globals,
)
- assert res.result == {"httpResponse": {"status": 400, "body": "Signing secret not configured"}}
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
def test_missing_signature_headers_returns_400(self):
globals = {
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/slack/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/slack/webhook_template.py
index a78e61a23463..30902583f6a1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/slack/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/slack/webhook_template.py
@@ -32,9 +32,10 @@ if (not inputs.bypass_signature_check and not (isUrlVerification and empty(input
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/tests/test_sparkpost_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/tests/test_sparkpost_webhook_template.py
index f311b842caac..36f460d43858 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/tests/test_sparkpost_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/tests/test_sparkpost_webhook_template.py
@@ -86,12 +86,15 @@ class TestSparkPostWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
assert res.result["httpResponse"]["status"] == expected_status
self.mock_produce_to_warehouse_webhooks.assert_not_called()
- def test_delivery_is_rejected_when_no_credentials_are_configured(self):
+ def test_delivery_is_dropped_when_no_credentials_are_configured(self):
res = self.run_function(
self._inputs(authorization_header=""), globals=self._request(self._batch(), header="Basic anything")
)
- assert res.result == {"httpResponse": {"status": 400, "body": "Authorization header value not configured"}}
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Authorization header value not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
self.mock_produce_to_warehouse_webhooks.assert_not_called()
def test_events_table_not_enabled_is_acknowledged_and_dropped(self):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/webhook_template.py
index 22a8bc1dada9..a24482c22f55 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sparkpost/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_authorization_check) {
if (empty(inputs.authorization_header)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Authorization header value not configured',
- }
+ 'status': 200,
+ 'body': 'Authorization header value not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_webhook_template.py
index 9058dabb68c9..434190d9c60d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_webhook_template.py
@@ -140,7 +140,7 @@ class TestStripeWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
("empty_string", ""),
]
)
- def test_missing_signing_secret_returns_400(self, _name, signing_secret):
+ def test_missing_signing_secret_drops_delivery(self, _name, signing_secret):
globals = {
"request": {
"method": "POST",
@@ -151,7 +151,10 @@ class TestStripeWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
}
}
res = self.run_function({"signing_secret": signing_secret, "bypass_signature_check": False}, globals=globals)
- assert res.result == {"httpResponse": {"status": 400, "body": "Signing secret not configured"}}
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
@parameterized.expand(
[
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/webhook_template.py
index 16ff30a0e373..058993fbeecd 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/uppromote/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/uppromote/webhook_template.py
index 7490f27088c9..8b32f371e3f4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/uppromote/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/uppromote/webhook_template.py
@@ -30,9 +30,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/source.py
index a53583350ec2..ba63a0bee341 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/source.py
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Optional, cast
+from typing import TYPE_CHECKING, Any, Optional, cast
import structlog
@@ -194,6 +194,21 @@ class WebflowSource(
# drift anyway: `create_webhook` registers every trigger the one eligible table needs, and
# anything missing afterwards is surfaced to the user by `get_desired_webhook_events`.
+ def missing_webhook_inputs(self, inputs: dict[str, Any]) -> list[str]:
+ # Webflow issues one secret per trigger, at creation only, and keeps them in the hidden
+ # `signing_secrets`. A partial capture still needs a manual secret for the triggers whose
+ # secret we never saw, so completeness decides rather than the presence of the list.
+ # `create_webhook` records completeness separately, because a set secret serializes to a
+ # masked marker that cannot be counted here.
+ complete = inputs.get("signing_secrets_complete", {}).get("value")
+ if complete:
+ return []
+ # Registered before PostHog recorded completeness. Keep the earlier reading, so a webhook
+ # the provider fully provisioned is not now reported as needing setup.
+ if complete is None and inputs.get("signing_secrets", {}).get("secret"):
+ return []
+ return super().missing_webhook_inputs(inputs)
+
def get_external_webhook_info(
self, config: WebflowSourceConfig, webhook_url: str, team_id: int, api_version: str | None = None
) -> ExternalWebhookInfo | None:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.py
index 43ee22fb5b2b..9b711d06078d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.py
@@ -347,7 +347,7 @@ class TestCreateWebhook:
result = create_webhook("token", "site-1", "https://webhooks.example/dwh/1")
assert result.success is True
- assert result.extra_inputs == {"signing_secrets": ["s1", "s2"]}
+ assert result.extra_inputs == {"signing_secrets": ["s1", "s2"], "signing_secrets_complete": True}
assert result.pending_inputs == []
assert [call.kwargs["json"]["triggerType"] for call in session.post.call_args_list] == list(ALL_WEBHOOK_EVENTS)
assert {call.kwargs["json"]["url"] for call in session.post.call_args_list} == {
@@ -372,6 +372,10 @@ class TestCreateWebhook:
assert result.success is True
# One trigger's secret was issued before we asked, so it can't be recovered.
assert result.pending_inputs == ["signing_secret"]
+ # A non-empty secret list does not mean setup is done. Without this flag the webhook tab
+ # reads the list as complete and hides the warning, while the triggers whose secret we
+ # never saw keep failing the signature check.
+ assert result.extra_inputs == {"signing_secrets": ["s2"], "signing_secrets_complete": False}
def test_registration_without_a_secret_asks_the_user_for_one(self) -> None:
# Site tokens predating Webflow's per-webhook secrets return no secretKey; silently
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_source.py
index d40dc475993f..3ed89b79d19e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_source.py
@@ -157,6 +157,34 @@ class TestWebflowWebhookSupport:
) -> None:
assert WebflowSource().get_desired_webhook_events(_config(), enabled) == expected
+ @parameterized.expand(
+ [
+ (
+ "every_trigger_secret_captured",
+ {"signing_secrets": {"secret": True}, "signing_secrets_complete": {"value": True}},
+ [],
+ ),
+ # Webflow returns a secret only for the triggers it registered this time. The rest cannot
+ # be verified, so the manual secret is still required even though the list is non-empty.
+ (
+ "only_some_trigger_secrets_captured",
+ {
+ "signing_secrets": {"secret": True},
+ "signing_secrets_complete": {"value": False},
+ "signing_secret": {"value": ""},
+ },
+ ["signing_secret"],
+ ),
+ ("registered_before_completeness_was_recorded", {"signing_secrets": {"secret": True}}, []),
+ ("manual_secret", {"signing_secret": {"secret": True}}, []),
+ ("nothing_set", {"signing_secret": {"value": ""}}, ["signing_secret"]),
+ ]
+ )
+ def test_missing_webhook_inputs_tracks_provider_secret_completeness(
+ self, _name: str, inputs: dict, expected: list[str]
+ ) -> None:
+ assert WebflowSource().missing_webhook_inputs(inputs) == expected
+
@parameterized.expand(
[
("create", "create_webflow_webhook", "create_webhook"),
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_webhook_template.py
index a5a9d5cfe96c..bbfade17eda7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow_webhook_template.py
@@ -125,16 +125,30 @@ class TestWebflowWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
assert res.result == {"httpResponse": {"status": 400, "body": "Stale delivery"}}
self.mock_produce_to_warehouse_webhooks.assert_not_called()
+ def test_missing_signing_secret_drops_delivery(self) -> None:
+ body = self._event()
+ globals = {
+ "request": {
+ "method": "POST",
+ "headers": {"x-webflow-signature": "abc", "x-webflow-timestamp": "1700000000000"},
+ "body": body,
+ "stringBody": json.dumps(body),
+ "query": {},
+ }
+ }
+
+ res = self.run_function(self._inputs(signing_secret="", signing_secrets=[]), globals=globals)
+
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
+ self.mock_produce_to_warehouse_webhooks.assert_not_called()
+
@parameterized.expand(
[
("missing_signature", {"x-webflow-timestamp": "1700000000000"}, {}, "Missing signature"),
("missing_timestamp", {"x-webflow-signature": "abc"}, {}, "Missing signature"),
- (
- "no_secret_configured",
- {"x-webflow-signature": "abc", "x-webflow-timestamp": "1700000000000"},
- {"signing_secret": "", "signing_secrets": []},
- "Signing secret not configured",
- ),
]
)
def test_unverifiable_delivery_is_rejected(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.py
index 278677ef2334..db939c0b99cc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.py
@@ -253,8 +253,11 @@ def create_webhook(api_token: str, site_id: str, webhook_url: str) -> WebhookCre
# A secret we never saw can't be reconstructed — Webflow only returns it on create, and
# tokens predating its per-webhook secrets return none at all. Ask for one by hand so
# deliveries aren't silently rejected.
- pending_inputs = [] if len(secrets) == len(ALL_WEBHOOK_EVENTS) else ["signing_secret"]
- extra_inputs: dict[str, Any] = {"signing_secrets": secrets} if secrets else {}
+ complete = len(secrets) == len(ALL_WEBHOOK_EVENTS)
+ pending_inputs = [] if complete else ["signing_secret"]
+ extra_inputs: dict[str, Any] = (
+ {"signing_secrets": secrets, "signing_secrets_complete": complete} if secrets else {}
+ )
return WebhookCreationResult(success=True, extra_inputs=extra_inputs, pending_inputs=pending_inputs)
except Exception as e:
return WebhookCreationResult(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webhook_template.py
index e4902ec9c176..e474a9db6365 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webhook_template.py
@@ -48,9 +48,10 @@ if (not inputs.bypass_signature_check) {
if (empty(secrets)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
@@ -159,6 +160,19 @@ produceToWarehouseWebhooks(
"secret": True,
"hidden": True,
},
+ {
+ "type": "boolean",
+ "key": "signing_secrets_complete",
+ "label": "Signing secrets complete",
+ "description": (
+ "Whether PostHog captured a secret for every trigger type it registered. False means some "
+ "deliveries cannot be verified until a signing secret is entered by hand."
+ ),
+ "default": False,
+ "required": False,
+ "secret": False,
+ "hidden": True,
+ },
{
"type": "boolean",
"key": "bypass_signature_check",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/whop/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/whop/webhook_template.py
index b4b798f8afee..bae6b7b1c7cd 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/whop/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/whop/webhook_template.py
@@ -32,9 +32,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/tests/test_woocommerce_webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/tests/test_woocommerce_webhook_template.py
index 59ee3422d135..796c51d58f6f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/tests/test_woocommerce_webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/tests/test_woocommerce_webhook_template.py
@@ -141,15 +141,33 @@ class TestWooCommerceWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):
assert res.result == {"httpResponse": {"status": 400, "body": "Bad signature"}}
self.mock_produce_to_warehouse_webhooks.assert_not_called()
+ def test_missing_signing_secret_drops_delivery(self):
+ body = self._object()
+ globals = {
+ "request": {
+ "method": "POST",
+ "headers": {
+ "x-wc-webhook-resource": "order",
+ "x-wc-webhook-event": "updated",
+ "x-wc-webhook-signature": "x",
+ },
+ "body": body,
+ "stringBody": json.dumps(body),
+ "query": {},
+ }
+ }
+
+ res = self.run_function(self._inputs(signing_secret=""), globals=globals)
+
+ assert res.result == {
+ "httpResponse": {"status": 200, "body": "Signing secret not configured, delivery dropped"},
+ "appMetric": "missing_credential",
+ }
+ self.mock_produce_to_warehouse_webhooks.assert_not_called()
+
@parameterized.expand(
[
("missing_signature", {}, {"signing_secret": SIGNING_SECRET}, "Missing signature"),
- (
- "no_secret_configured",
- {"x-wc-webhook-signature": "x"},
- {"signing_secret": ""},
- "Signing secret not configured",
- ),
]
)
def test_unverifiable_delivery_is_rejected(self, _name, headers, input_overrides, expected_body):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/webhook_template.py
index 0505bfff7e62..64427324b4b5 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/woocommerce/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/workos/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/workos/webhook_template.py
index dacc28616b99..5c8226582f84 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/workos/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/workos/webhook_template.py
@@ -17,7 +17,10 @@ if (request.method != 'POST') {
if (not inputs.bypass_signature_check) {
if (empty(inputs.signing_secret)) {
- return {'httpResponse': {'status': 400, 'body': 'Signing secret not configured'}}
+ return {
+ 'httpResponse': {'status': 200, 'body': 'Signing secret not configured, delivery dropped'},
+ 'appMetric': 'missing_credential'
+ }
}
let signatureHeader := request.headers['workos-signature']
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/yousign/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/yousign/webhook_template.py
index 2c7ab70c738e..0706875d465e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/yousign/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/yousign/webhook_template.py
@@ -26,9 +26,10 @@ if (request.method != 'POST') {
if (empty(inputs.signing_secret)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Signing secret not configured',
- }
+ 'status': 200,
+ 'body': 'Signing secret not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py b/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py
index fc067c0f53c7..7d09fc3c6064 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/zapsign/webhook_template.py
@@ -24,9 +24,10 @@ if (not inputs.bypass_authorization_check) {
if (empty(inputs.authorization_header)) {
return {
'httpResponse': {
- 'status': 400,
- 'body': 'Authorization header value not configured',
- }
+ 'status': 200,
+ 'body': 'Authorization header value not configured, delivery dropped',
+ },
+ 'appMetric': 'missing_credential'
}
}
diff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.ts
index 2795fc54488a..4049b27eff3b 100644
--- a/products/warehouse_sources/frontend/generated/api.schemas.ts
+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts
@@ -5279,6 +5279,8 @@ export interface WebhookInfoResponseApi {
external_status: WebhookExternalStatusApi | null
/** Desired provider events not yet on the webhook (manual setup, or created before a new table). */
missing_events?: string[]
+ /** Required webhook field names with no value yet. Deliveries are dropped while any is missing. */
+ missing_inputs?: string[]
}
export interface CdcPrerequisitesResponseApi {
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index cc15f416765e..78e772c9b7e4 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -102009,6 +102009,8 @@ export namespace Schemas {
external_status: WebhookExternalStatus | null;
/** Desired provider events not yet on the webhook (manual setup, or created before a new table). */
missing_events?: string[];
+ /** Required webhook field names with no value yet. Deliveries are dropped while any is missing. */
+ missing_inputs?: string[];
}
export interface WebhookUrl {