Skip to content

Generated types not consistently reproducable #959

@dangbert

Description

@dangbert

Describe the bug
Since upgrading to Supbase CLI version 2.24.3 and upgrading my Supbase major_version from 15 -> 17 at the same time, my generated typescript types are flaky (the output file flips between one of two versions between successive generations).

To Reproduce
Steps to reproduce the behavior:

  1. Init a supabase project locally with major_version 17 in config.toml and these npm package version:
├── [email protected]
├── [email protected]
├── @supabase/[email protected]
├── [email protected]
├── [email protected]
  1. Run npx supabase start and create any empty table at http://localhost:54323/project/default/editor then run npx supabase db dump --data-only --linked -f ./supabase/seed.sql && npx supabase db diff -f "init"

  2. npx supbase db reset && npx supabase gen types typescript --local > supabase.ts

  3. Rerun the previous command several times and observe that this section of supbase.ts varies between the following values:

Variation A:

export type Database = {
  graphql_public: {
    Tables: {
      [_ in never]: never
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      graphql: {
        Args: {
          operationName?: string
          query?: string
          variables?: Json
          extensions?: Json
        }
        Returns: Json
      }
    }
    Enums: {
      [_ in never]: never
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
...

and variation B:

export type Database = {
  graphql_public: {
    Tables: {
      [_ in never]: never
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      graphql: {
        Args: {
          variables?: Json
          extensions?: Json
          operationName?: string
          query?: string
        }
        Returns: Json
      }
    }
    Enums: {
      [_ in never]: never
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
...

Where the diff looks like this:

+++ b/supabase.ts
@@ -17,10 +17,10 @@ export type Database = {
     Functions: {
       graphql: {
         Args: {
-          operationName?: string
-          query?: string
           variables?: Json
           extensions?: Json
+          operationName?: string
+          query?: string
         }
         Returns: Json
       }

Expected behavior
The generated file, supabase.ts should be reproducible and exactly identical every time it's created (provided there are no changes to the database schema).

My use case is I run npx supbase db reset && npx supabase gen types typescript --local > supabase.ts in my CI and have it fail if there's a diff for supabase.ts as this indicates I forgot to regenerate this file and update it in in the git repo after adding a migration to my PR that changes schemas.

This process was working fine until I upgrade my dependencies today (listed above) and upgrade to major_version 17 (from 15) in supbase/config.toml at the same time.

Screenshots
If applicable, add screenshots to help explain your problem.

System information
Rerun the failing command with --create-ticket flag.

(No command was failing so I couldn't produce this but I'm manually filling in):

  • Ticket ID:

  • Version of OS: MacOS Sequoia (15.5)

  • Version of CLI: v2.24.3

  • Version of Docker: 24.0.2, build cb74dfc

  • Versions of services:

    SERVICE IMAGE | LOCAL | LINKED
    ------------------------|------------------------|------------
    supabase/postgres | 17.4.1.038 | 17.4.1.037
    supabase/gotrue | v2.174.0 | v2.174.0
    postgrest/postgrest | v12.2.3 | v12.2.3
    supabase/realtime | v2.36.7 | -
    supabase/storage-api | v1.23.0 | -
    supabase/edge-runtime | v1.67.4 | -
    supabase/studio | 2025.06.02-sha-8f2993d | -
    supabase/postgres-meta | v0.89.3 | -
    supabase/logflare | 1.12.0 | -
    supabase/supavisor | 2.5.1 | -

Additional context
If applicable, add any other context about the problem here.

It seems that npx supbase db reset is critical before running npx supabase gen types typescript --local > supabase.ts to cause the reproducibility issues. I can run the second command many times back to back without a file diff, but only when combined with npx supbase db reset does it make the output file alter between the two variations I described.

Note I also don't use graphql in my project. If there was an option to skip outputting graphql that'd also be an okay workaround for now for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions