Skip to content
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

fix(querying): Use appropriate HTTP status for async queries #21175

Merged
merged 9 commits into from
Mar 28, 2024

Conversation

Twixes
Copy link
Collaborator

@Twixes Twixes commented Mar 26, 2024

Problem

In the experimental async queries system, we were always returning a 200 even if things went wrong, and we were unsafely always returning the error when things went wrong. Related to ZEN-12040

Changes

We now use HTTP status codes appropriately, and are more deliberate with errors.

How did you test this code?

Updated API tests.

Copy link
Contributor

github-actions bot commented Mar 26, 2024

Size Change: 0 B

Total Size: 824 kB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 824 kB

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@Twixes Twixes merged commit 106a6a9 into master Mar 28, 2024
83 checks passed
@Twixes Twixes deleted the fix-async-calculation branch March 28, 2024 21:39
Copy link
Contributor

@webjunkie webjunkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing after merge:

Mhm... the reasoning here was that the GET/retrieve call mostly successfully retrieves the status of the async query.

Imagine as frontend, you are querying the status, get 200 means you got the status, then checking whether the query erred is on a different level. Returning a bad request or server errors means we cannot distinguish from the "get status" failing vs. the actual query having failed.

Was there no way to look into the error inside the status instead?

@Twixes
Copy link
Collaborator Author

Twixes commented Apr 2, 2024

I agree what you're describing definitely makes sense as one way of handling status @webjunkie Here the immediate issue is that all of our pre-existing API request code has handling for HTTP errors, so by reusing that, we can avoid that new handling to also check the query status body.
HTTP status codes do also make for a standard obvious experience – I'd say 200 vs. 202 is a must-have – though I agree 400 and 500 are one area that's a bit gray. They do refer to the request itself more than the resource… Would leave them as is for the existing error handling though.

Copy link

sentry-io bot commented Apr 3, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: Property.init() missing 1 required positional argument: 'key' posthog.tasks.tasks.process_query_task View Issue
  • ‼️ CHQueryErrorNoCommonType: Code: 386. posthog.tasks.tasks.process_query_task View Issue
  • ‼️ TypeError: Property.init() missing 1 required positional argument: 'key' posthog.tasks.tasks.process_query_task View Issue
  • ‼️ CHQueryErrorUnknownIdentifier: Code: 47. posthog.tasks.tasks.process_query_task View Issue
  • ‼️ CHQueryErrorNoCommonType: Code: 386. posthog.tasks.tasks.process_query_task View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants