: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(file-system): allow log_view tracking POSTs through read-only guard (#59642)
posthog[bot]69317801a928
diff --git a/frontend/src/lib/readOnlyGuard.test.ts b/frontend/src/lib/readOnlyGuard.test.tsindex 9ecc50b75f7c..8486d9d4e9a6 100644--- a/frontend/src/lib/readOnlyGuard.test.ts+++ b/frontend/src/lib/readOnlyGuard.test.ts@@ -82,6 +82,8 @@ describe('readOnlyGuard', () => {['query log', 'POST', '/api/environments/2/query/abc-123/log'],['query with trailing query string', 'POST', '/api/environments/2/query/?refresh=true'],['delete on query path', 'DELETE', '/api/environments/2/query/abc-123/'],+ ['file system log view', 'POST', '/api/environments/2/file_system/log_view/'],+ ['log view with query string', 'POST', '/api/environments/2/file_system/log_view/?foo=bar'],] as const)('lets %s through (%s %s)', (_label, method, url) => {const notifier = jest.fn()setReadOnlyNotifier(notifier)@@ -92,7 +94,9 @@ describe('readOnlyGuard', () => {it.each([['endpoint that just contains the word query in a name', 'POST', '/api/environments/2/queryless/'],['similar prefix without slash', 'POST', '/api/environments/2/queryteam/'],- ] as const)('still blocks %s (%s %s) — only paths with /query/ segment are allowed', (_l, method, url) => {+ ['file system entity write blocked', 'POST', '/api/environments/2/file_system/'],+ ['file system non-log_view blocked', 'POST', '/api/environments/2/file_system/abc-123/move'],+ ] as const)('still blocks %s (%s %s) — only allowlisted paths pass', (_l, method, url) => {expect(() => assertNotReadOnly(method, url)).toThrow(ReadOnlyModeError)})})diff --git a/frontend/src/lib/readOnlyGuard.ts b/frontend/src/lib/readOnlyGuard.tsindex d357d33f5b48..09e92a1ebf10 100644--- a/frontend/src/lib/readOnlyGuard.ts+++ b/frontend/src/lib/readOnlyGuard.ts@@ -44,12 +44,15 @@ export function isReadOnly(): boolean {return getter?.() ?? false}-// URLs that look like writes but are actually reads. The query endpoint is the-// obvious one — it serves HogQL / trends / funnels / retention via POST because-// the payload is too large for a query string. Block-listing these would make-// the entire app unusable in read-only mode.+// Writes that should pass through in read-only mode. Two categories:+// 1. Reads disguised as writes — /query serves HogQL / trends / funnels /+// retention via POST because the payload is too large for a query string.+// Block-listing it would make the entire app unusable.+// 2. Passive telemetry — /file_system/log_view records that the user viewed+// a log, which happens automatically on mount and should not raise.const READ_ONLY_ALLOWED_PATTERNS = [/\/query(?:\/|$|\?)/, // /api/environments/:team_id/query, /api/environments/:team_id/query/:queryId/log, etc.+ /\/file_system\/log_view(?:\/|$|\?)/, // /api/environments/:team_id/file_system/log_view]function isReadDisguisedAsWrite(url: string): boolean {