-
Notifications
You must be signed in to change notification settings - Fork 514
Ask AI Huge Response #1328
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
Merged
Merged
Ask AI Huge Response #1328
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
39a9a7d
initial commit
aadesh18 5170627
Merge branch 'dev' into ask-ai-huge-responses-fix
aadesh18 443e26c
pr comments
aadesh18 70f3daa
Merge branch 'dev' into ask-ai-huge-responses-fix
aadesh18 4d030b4
pr comment
aadesh18 9ecd491
Merge remote-tracking branch 'origin/dev' into ask-ai-huge-responses-fix
aadesh18 40e15fc
merge
aadesh18 538166c
Merge branch 'dev' into ask-ai-huge-responses-fix
aadesh18 ffacab2
Merge branch 'dev' into ask-ai-huge-responses-fix
aadesh18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { getNodeEnvironment } from "@stackframe/stack-shared/dist/utils/env"; | ||
| import { captureError, StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors"; | ||
|
|
||
| const SAFE_CLICKHOUSE_ERROR_CODES = [ | ||
| 62, // SYNTAX_ERROR | ||
| 159, // TIMEOUT_EXCEEDED | ||
| 164, // READONLY | ||
| 158, // TOO_MANY_ROWS | ||
| 396, // TOO_MANY_ROWS_OR_BYTES | ||
| 636, // CANNOT_EXTRACT_TABLE_STRUCTURE | ||
| ]; | ||
|
|
||
| const UNSAFE_CLICKHOUSE_ERROR_CODES = [ | ||
| 36, // BAD_ARGUMENTS | ||
| 43, // ILLEGAL_TYPE_OF_ARGUMENT | ||
| 47, // UNKNOWN_IDENTIFIER | ||
| 60, // UNKNOWN_TABLE | ||
| 497, // ACCESS_DENIED | ||
| ]; | ||
|
|
||
| const DEFAULT_CLICKHOUSE_ERROR_MESSAGE = "Error during execution of this query."; | ||
|
|
||
| export function getSafeClickhouseErrorMessage(error: unknown, query: string) { | ||
| if (typeof error !== "object" || error === null || !("code" in error) || typeof error.code !== "string" || isNaN(Number(error.code)) || !("message" in error) || typeof error.message !== "string") { | ||
| captureError("unknown-clickhouse-error-for-query-not-clickhouse-error", new StackAssertionError("Unknown error from Clickhouse is not a Clickhouse error", { cause: error, query: query })); | ||
| return DEFAULT_CLICKHOUSE_ERROR_MESSAGE; | ||
| } | ||
|
|
||
| const errorCode = Number(error.code); | ||
| const message = error.message; | ||
| if (SAFE_CLICKHOUSE_ERROR_CODES.includes(errorCode)) { | ||
| return message; | ||
| } | ||
| const isKnown = UNSAFE_CLICKHOUSE_ERROR_CODES.includes(errorCode); | ||
| if (!isKnown) { | ||
| captureError("unknown-clickhouse-error-for-query", new StackAssertionError(`Unknown Clickhouse error: code ${errorCode} not in safe or unsafe codes`, { cause: error, query: query })); | ||
| } | ||
|
|
||
| if (getNodeEnvironment() === "development" || getNodeEnvironment() === "test") { | ||
| return `${DEFAULT_CLICKHOUSE_ERROR_MESSAGE}${!isKnown ? "\n\nThis error is not known and you should probably add it to the safe or unsafe codes in clickhouse-errors.ts." : ""}\n\nAs you are in development mode, you can see the full error: ${errorCode} ${message}`; | ||
| } | ||
| return DEFAULT_CLICKHOUSE_ERROR_MESSAGE; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.