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

chore(data-warehouse): Dont allow deleting of tables with a source #29233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gilbert09
Copy link
Member

Problem

  • This isn't possible from the frontend right now, but it is possible via our frontend API and so I just wanna make a guard on the backend to make sure sourced tables dont get deleted

Changes

  • Dont allow deletions of Table objects if attempted via the API

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Added tests

@Gilbert09 Gilbert09 requested a review from a team February 26, 2025 09:37
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR adds a guard in the TableViewSet.destroy method to prevent deletion of data warehouse tables that have an associated external data source.

  • Added validation in posthog/warehouse/api/table.py that returns a 400 error if attempting to delete a table with an external data source
  • Added two test cases in posthog/warehouse/api/test/test_table.py to verify both successful deletion of regular tables and blocked deletion of sourced tables
  • Fixed a typo in the variable name from 'souce' to 'source' in the existing test_update_schema_400_with_source test
  • This is a defensive backend measure since the frontend already prevents this action

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

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.

1 participant