Skip to content

TypeScript type generation produces inconsistent field ordering causing diff failures in CI #968

@Red-Asuka

Description

@Red-Asuka

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The supabase gen types typescript command generates TypeScript types with inconsistent field ordering, causing git diff failures in CI pipelines. The same database schema produces different field orders across different runs, making it impossible to maintain consistent type definitions in version control.

To Reproduce

Steps to reproduce the behavior:

  1. Set up a GitHub Actions workflow with the following configuration:
jobs:
  test-migrations:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: supabase/setup-cli@v1
        with:
          version: 2.26.9
      - name: Start Supabase local development setup
        run: supabase db start
      - name: Verify generated types are checked in
        run: |
          supabase gen types typescript --local > types/schema.gen.ts
          if ! git diff --ignore-space-at-eol --exit-code --quiet types/schema.gen.ts; then
            echo "Detected uncommitted changes after build. See status below:"
            git diff
            exit 1
          fi
  1. Run the workflow multiple times
  2. Observe that the generated types have different field orders each time
  3. See the diff failure in CI
--- a/types/schema.gen.ts
+++ b/types/schema.gen.ts
@@ -17,10 +17,10 @@ export type Database = {
     Functions: {
       graphql: {
         Args: {
-          extensions?: Json
-          operationName?: string
           query?: string
+          operationName?: string
           variables?: Json
+          extensions?: Json
         }
         Returns: Json
       }
Error: Process completed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions