Skip to content

SQL editor “Save as view” allows invalid names (spaces) and closes modal when also creating a new folder; should block with inline validation #62009

Closed

Description

@erinozolins

Bug Description

Please describe.
When saving a SQL view via “Save as insight → Save as view,” the modal allows invalid names with spaces only when you are also creating a NEW folder in the same flow. In that case, the modal closes and only a toast error appears, which makes it look like the view saved when it didn’t.
If the folder already exists, the modal correctly shows an error and blocks save — so this seems specific to the “create new folder + save view” path.

If this affects the front-end, screenshots would be of great help.
Here’s a short screencast

If you are on PostHog Cloud it would be really valuable if you can share any links where the problem occurs. This speeds up our ability to troubleshoot tremendously.
SQL query URL

How to reproduce

  1. Open SQL editor in a PostHog Cloud project
  2. Click Save as insight → Save as view
  3. Choose Create new folder
  4. Create a new folder with any name, THEN
  5. Enter a view name with spaces (e.g. “Revenue last 30 days”)
  6. Click Save
  7. Observe: toast error + modal closes (view not saved)
    Control case:
    If you choose an existing folder and use the same invalid name, the modal shows an error and blocks saving (expected behavior).

Additional context

  • View names appear to be validated server-side only in the new folder flow; UI should block invalid names before save.
  • Related review comment in PR #52964 flagged missing client-side validation for invalid view names.

Debug info

- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables or https://eu.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]

Activity

  1. added
    bug
    on Jun 6, 2026
  2. changed the title [-]SQL editor “Save as view” allows invalid names (spaces) and closes modal; should block with inline validation[/-] [+]SQL editor “Save as view” allows invalid names (spaces) and closes modal when also creating a new folder; should block with inline validation[/+] on Jun 6, 2026
  3. vmaineng commented on Jun 10, 2026

    @vmaineng
    Contributor

    Hi Erin! Quick question, may I ask what the use case for wanting spaces in view names? I'm trying to understand if this is more of a readability thing (wanting names like "Weekly Active Users" instead of "weekly_active_users").

    Just flagging that spaces in SQL identifiers cause parsing issues since the SQL engine reads them as separate tokens, i.e.: CREATE VIEW my view name breaks without quoting whereas CREATE VIEW my_view_name AS is deemed better.

    If it's purely a readability concern, one middle ground could be allowing spaces in a display name field while auto-converting to underscores for the actual SQL identifier — so users see "Weekly Active Users" but the view is saved as weekly_active_users. Would something like that solve your problem?

  4. erinozolins commented on Jun 10, 2026

    @erinozolins
    Author

    @vmaineng Yes, this is a readability thing - Your idea to allow spaces in a display name field while auto-converting to underscores for the SQL identifier sounds great! That would definitely solve the problem.

  5. darkopia commented on Nov 7, 2026

    @darkopia
    Contributor

    Closing because the Save as view dialog now keeps its own validation when you create a folder from it, fixed in #62113. Add a comment if this was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions