fix: respect DISABLE_FLOWISE_TELEMETRY env var for telemetry opt-out#6637
fix: respect DISABLE_FLOWISE_TELEMETRY env var for telemetry opt-out#6637zzhzhangzhihao wants to merge 2 commits into
Conversation
- Previously only escaped/unescaped '-' character
- Now handles all RediSearch reserved characters: , . < > { } [ ] " ' : ; ! @ # $ % ^ & * ( ) - + = ~
- Fixes JSON.parse failure when metadata contains special characters (FlowiseAI#6598)
- Previously DISABLE_FLOWISE_TELEMETRY was documented in .env.example, docker-compose files, and CLI flags, but never actually checked in code. - Only POSTHOG_PUBLIC_API_KEY controlled telemetry behavior. - Now the Telemetry constructor checks DISABLE_FLOWISE_TELEMETRY before initializing PostHog, allowing users to opt out of telemetry as documented. Fixes FlowiseAI#6618
There was a problem hiding this comment.
Code Review
This pull request introduces an opt-out mechanism for telemetry via the DISABLE_FLOWISE_TELEMETRY environment variable and expands the unEscapeSpecialChars utility in the Redis vector store to handle additional RediSearch special characters. A critical issue was identified in the unescaping logic where single and double quotes are not properly unescaped because the backslashes themselves are not escaped in the string literals, which will cause JSON parsing failures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| '\"', '"', | ||
| "\'", "'", |
There was a problem hiding this comment.
In JavaScript/TypeScript, the backslash in '\"' and "\'" acts as an escape character for the quote character itself within the string literal. Since double quotes do not need to be escaped inside single quotes (and vice versa), '\"' evaluates to " (length 1) and "\'" evaluates to ' (length 1).
As a result, the loop executes str.replaceAll('"', '"') and str.replaceAll("'", "'"), which does nothing and fails to unescape the actual backslash-escaped quotes (e.g., \" and \\') returned by Redis. This will cause JSON.parse to fail when parsing metadata containing quotes.
To fix this, escape the backslash itself so that the search strings are of length 2 (representing a literal backslash followed by a quote).
| '\"', '"', | |
| "\'", "'", | |
| '\\"', '"', | |
| "\\'", "'", |
What
Makes the Telemetry constructor actually respect the DISABLE_FLOWISE_TELEMETRY environment variable.
Why
DISABLE_FLOWISE_TELEMETRY is documented as a telemetry opt-out in .env.example files, docker-compose files, and CLI flags. However, no code actually reads it. The only thing controlling telemetry was whether POSTHOG_PUBLIC_API_KEY is set.
Fix
Updated the Telemetry constructor in packages/server/src/utils/telemetry.ts to check DISABLE_FLOWISE_TELEMETRY before initializing PostHog. If the env var is 'true' or '1', telemetry is disabled regardless of POSTHOG_PUBLIC_API_KEY.
Related