-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(errors): return 400 for ClickHouse type-coercion parse errors #92068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
68fd381
70ba776
959a848
0943714
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,7 @@ | |
| ) | ||
|
|
||
|
|
||
| def wrap_clickhouse_query_error(err: Exception) -> Exception: | ||
|
Check warning on line 107 in posthog/errors.py
|
||
| "Beautifies clickhouse client errors, using custom error classes for every code" | ||
| if not isinstance(err, ServerException): | ||
| return err | ||
|
|
@@ -367,9 +367,13 @@ | |
| 2: ErrorCodeMeta("UNSUPPORTED_PARAMETER"), | ||
| 3: ErrorCodeMeta("UNEXPECTED_END_OF_FILE"), | ||
| 4: ErrorCodeMeta("EXPECTED_END_OF_FILE"), | ||
| # Stays internal: the CH message embeds the failing data value, which would leak stored | ||
| # data to anonymous viewers of public shared insights. Only user_safe once sanitized. | ||
| 6: ErrorCodeMeta("CANNOT_PARSE_TEXT", category=QueryErrorCategory.USER_ERROR), | ||
| # Fixed message: the raw CH text embeds the failing data value, which would leak stored data | ||
| # to anonymous viewers of public shared insights. A fixed string keeps that value out of the | ||
| # response while still returning a 400 for the bad query (see also codes 26, 72, 130). | ||
| 6: ErrorCodeMeta( | ||
| "CANNOT_PARSE_TEXT", | ||
| user_safe="Cannot parse a value in the query as text. Check the types in your comparisons and IN clauses.", | ||
| ), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not treat broad parser codes as query-only failuresWhy we think it's a valid issue
Issue description
Suggested fixKeep unmatched messages internal. Add a dedicated exposed exception for recognized coercion signatures in Prompt to fix with AI (copy-paste)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Escalating this for a human decision rather than changing it unattended. The finding is real: adding fixed
posthog[bot] marked this conversation as resolved.
Outdated
|
||
| 7: ErrorCodeMeta("INCORRECT_NUMBER_OF_COLUMNS"), | ||
| 8: ErrorCodeMeta("THERE_IS_NO_COLUMN"), | ||
| 9: ErrorCodeMeta("SIZES_OF_COLUMNS_DOESNT_MATCH"), | ||
|
|
@@ -384,7 +388,11 @@ | |
| 23: ErrorCodeMeta("CANNOT_READ_FROM_ISTREAM"), | ||
| 24: ErrorCodeMeta("CANNOT_WRITE_TO_OSTREAM"), | ||
| 25: ErrorCodeMeta("CANNOT_PARSE_ESCAPE_SEQUENCE"), | ||
| 26: ErrorCodeMeta("CANNOT_PARSE_QUOTED_STRING"), | ||
| # Fixed message: same type-coercion family as code 6, and the raw CH text embeds the value. | ||
| 26: ErrorCodeMeta( | ||
| "CANNOT_PARSE_QUOTED_STRING", | ||
| user_safe="Cannot parse a value in the query as a quoted string. Check the types in your comparisons and IN clauses.", | ||
| ), | ||
| 27: ErrorCodeMeta("CANNOT_PARSE_INPUT_ASSERTION_FAILED"), | ||
| 28: ErrorCodeMeta("CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER"), | ||
| 32: ErrorCodeMeta("ATTEMPT_TO_READ_AFTER_EOF"), | ||
|
|
@@ -432,8 +440,11 @@ | |
| user_safe="Cannot convert one type to another in the query. Check the types in your comparisons and IN clauses.", | ||
| ), | ||
| 71: ErrorCodeMeta("CANNOT_WRITE_AFTER_END_OF_BUFFER"), | ||
| # 72 stays internal: the CH message embeds the failing data value (see code 6 note). | ||
| 72: ErrorCodeMeta("CANNOT_PARSE_NUMBER", category=QueryErrorCategory.USER_ERROR), | ||
| # Fixed message: same type-coercion family as code 6, and the raw CH text embeds the value. | ||
| 72: ErrorCodeMeta( | ||
| "CANNOT_PARSE_NUMBER", | ||
| user_safe="Cannot parse a value in the query as a number. Check the types in your comparisons and IN clauses.", | ||
| ), | ||
| 73: ErrorCodeMeta("UNKNOWN_FORMAT"), | ||
| 74: ErrorCodeMeta("CANNOT_READ_FROM_FILE_DESCRIPTOR"), | ||
| 75: ErrorCodeMeta("CANNOT_WRITE_TO_FILE_DESCRIPTOR"), | ||
|
|
@@ -484,7 +495,11 @@ | |
| 127: ErrorCodeMeta("ILLEGAL_INDEX"), | ||
| 128: ErrorCodeMeta("TOO_LARGE_ARRAY_SIZE"), | ||
| 129: ErrorCodeMeta("FUNCTION_IS_SPECIAL"), | ||
| 130: ErrorCodeMeta("CANNOT_READ_ARRAY_FROM_TEXT"), | ||
| # Fixed message: same type-coercion family as code 6, and the raw CH text embeds the value. | ||
| 130: ErrorCodeMeta( | ||
| "CANNOT_READ_ARRAY_FROM_TEXT", | ||
| user_safe="Cannot parse a value in the query as an array. Check the types in your comparisons and IN clauses.", | ||
| ), | ||
| 131: ErrorCodeMeta("TOO_LARGE_STRING_SIZE"), | ||
| 133: ErrorCodeMeta("AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS"), | ||
| 134: ErrorCodeMeta("PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS"), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.