nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: phoenixframework/phoenix
Pull request #2200 (2017-03-19 22:19:33)

[WIP] Persist resp_headers and other conn data on NoRouteError
Related to #2198.

AndrewDryga: Flaky test.

Patch:
diff --git a/lib/phoenix/endpoint/render_errors.ex b/lib/phoenix/endpoint/render_errors.ex
index 9f5033bf8..e28829275 100644
--- a/lib/phoenix/endpoint/render_errors.ex
+++ b/lib/phoenix/endpoint/render_errors.ex
@@ -51,6 +51,11 @@ defmodule Phoenix.Endpoint.RenderErrors do
     __catch__(conn, kind, reason, System.stacktrace, opts)
   end
 
+  defp __catch__(_conn, :error, %Phoenix.Router.NoRouteError{} = reason, stack, opts) do
+    maybe_render(reason.conn, :error, reason, stack, opts)
+    :erlang.raise(:error, reason, stack)
+  end
+
   defp __catch__(conn, kind, reason, stack, opts) do
     maybe_render(conn, kind, reason, stack, opts)
     :erlang.raise(kind, reason, stack)


Test patch:
diff --git a/test/phoenix/endpoint/render_errors_test.exs b/test/phoenix/endpoint/render_errors_test.exs
index 7709ae4f9..8f762cff6 100644
--- a/test/phoenix/endpoint/render_errors_test.exs
+++ b/test/phoenix/endpoint/render_errors_test.exs
@@ -230,4 +230,13 @@ defmodule Phoenix.Endpoint.RenderErrorsTest do
       |> render([], fn -> throw :hello end)
     end) == ""
   end
+
+  test "exception page for NoRouteError with plug_status 404" do
+    conn = render(conn(:get, "/"), [], fn ->
+      raise Phoenix.Router.NoRouteError, conn: conn(:get, "/"), router: nil, plug_status: 404
+    end)
+
+    assert conn.status == 404
+    assert conn.resp_body == "Got 404 from error with GET"
+  end
 end
Repository: supabase/cli
Pull request #991 (2023-04-05 15:37:50)

fix: revert entrypoint when using initial schema
## What kind of change does this PR introduce?

Bug fix https://github.com/supabase/cli/issues/980

## What is the new behavior?

fixes missing function error.

## Additional context

tested locally with a migration file



Patch:
diff --git a/internal/db/diff/migra.go b/internal/db/diff/migra.go
index 0175352d..f09aebbb 100644
--- a/internal/db/diff/migra.go
+++ b/internal/db/diff/migra.go
@@ -85,6 +85,7 @@ func LoadUserSchemas(ctx context.Context, conn *pgx.Conn, exclude ...string) ([]
 	// Include auth,storage,extensions by default for RLS policies
 	if len(exclude) == 0 {
 		exclude = append([]string{
+			"_analytics",
 			"pgbouncer",
 			"realtime",
 			"_realtime",
@@ -120,6 +121,7 @@ func likeEscapeSchema(schemas []string) (result []string) {
 
 func CreateShadowDatabase(ctx context.Context) (string, error) {
 	config := start.NewContainerConfig()
+	config.Entrypoint = []string{"docker-entrypoint.sh"}
 	hostPort := strconv.FormatUint(uint64(utils.Config.Db.ShadowPort), 10)
 	hostConfig := container.HostConfig{
 		PortBindings: nat.PortMap{"5432/tcp": []nat.PortBinding{{HostPort: hostPort}}},
diff --git a/internal/db/start/start.go b/internal/db/start/start.go
index 87678643..89e2b328 100644
--- a/internal/db/start/start.go
+++ b/internal/db/start/start.go
@@ -81,6 +81,7 @@ func StartDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...f
 		Binds:         []string{utils.DbId + ":/var/lib/postgresql/data"},
 	})
 	if utils.Config.Db.MajorVersion <= 14 {
+		config.Entrypoint = []string{"docker-entrypoint.sh"}
 		hostConfig.Tmpfs = map[string]string{"/docker-entrypoint-initdb.d": ""}
 	}
 	fmt.Fprintln(w, "Starting database...")


Test patch:
diff --git a/internal/db/diff/migra_test.go b/internal/db/diff/migra_test.go
index 54931c6e..90e3c2e2 100644
--- a/internal/db/diff/migra_test.go
+++ b/internal/db/diff/migra_test.go
@@ -105,7 +105,7 @@ func TestRunMigra(t *testing.T) {
 		// Setup mock postgres
 		conn := pgtest.NewConn()
 		defer conn.Close(t)
-		conn.Query(`SELECT schema_name FROM information_schema.schemata WHERE NOT schema_name LIKE ANY('{pgbouncer,realtime,"\\_realtime","supabase\\_functions","supabase\\_migrations","information\\_schema","pg\\_%",cron,graphql,"graphql\\_public",net,pgsodium,"pgsodium\\_masks",pgtle,repack,tiger,"tiger\\_data","timescaledb\\_%","\\_timescaledb\\_%",topology,vault}') ORDER BY schema_name`).
+		conn.Query(`SELECT schema_name FROM information_schema.schemata WHERE NOT schema_name LIKE ANY('{"\\_analytics",pgbouncer,realtime,"\\_realtime","supabase\\_functions","supabase\\_migrations","information\\_schema","pg\\_%",cron,graphql,"graphql\\_public",net,pgsodium,"pgsodium\\_masks",pgtle,repack,tiger,"tiger\\_data","timescaledb\\_%","\\_timescaledb\\_%",topology,vault}') ORDER BY schema_name`).
 			ReplyError(pgerrcode.DuplicateTable, `relation "test" already exists`)
 		// Run test
 		err := RunMigra(context.Background(), []string{}, "", dbConfig, fsys, conn.Intercept)
Repository: supabase/cli
Pull request #1184 (2023-06-06 11:12:22)

fix: exclude auth schema from default diff
## What kind of change does this PR introduce?

Bug fix https://github.com/supabase/supabase/issues/12825

## What is the current behavior?

Too many mishaps with diffing auth and storage by default

## What is the new behavior?

auth and storage schemas can only be diffed with explicit `-s` flag

## Additional context

Add any other context or screenshots.



Patch:
diff --git a/internal/db/diff/migra.go b/internal/db/diff/migra.go
index 8fed56af..73b22586 100644
--- a/internal/db/diff/migra.go
+++ b/internal/db/diff/migra.go
@@ -79,13 +79,16 @@ func loadSchema(ctx context.Context, config pgconn.Config, options ...func(*pgx.
 }
 
 func LoadUserSchemas(ctx context.Context, conn *pgx.Conn, exclude ...string) ([]string, error) {
-	// Include auth,storage,extensions by default for RLS policies
 	if len(exclude) == 0 {
+		// RLS policies in auth and storage schemas can be included with -s flag
 		exclude = append([]string{
-			"_analytics",
+			"auth",
+			// "extensions",
 			"pgbouncer",
 			"realtime",
 			"_realtime",
+			"storage",
+			"_analytics",
 			// Exclude functions because Webhooks support is early alpha
 			"supabase_functions",
 			"supabase_migrations",


Test patch:
diff --git a/internal/db/diff/migra_test.go b/internal/db/diff/migra_test.go
index f41c4546..ccfbe86f 100644
--- a/internal/db/diff/migra_test.go
+++ b/internal/db/diff/migra_test.go
@@ -106,7 +106,7 @@ func TestRunMigra(t *testing.T) {
 		// Setup mock postgres
 		conn := pgtest.NewConn()
 		defer conn.Close(t)
-		conn.Query(`SELECT schema_name FROM information_schema.schemata WHERE NOT schema_name LIKE ANY('{"\\_analytics",pgbouncer,realtime,"\\_realtime","supabase\\_functions","supabase\\_migrations","information\\_schema","pg\\_%",cron,graphql,"graphql\\_public",net,pgsodium,"pgsodium\\_masks",pgtle,repack,tiger,"tiger\\_data","timescaledb\\_%","\\_timescaledb\\_%",topology,vault}') ORDER BY schema_name`).
+		conn.Query(`SELECT schema_name FROM information_schema.schemata WHERE NOT schema_name LIKE ANY('{auth,pgbouncer,realtime,"\\_realtime",storage,"\\_analytics","supabase\\_functions","supabase\\_migrations","information\\_schema","pg\\_%",cron,graphql,"graphql\\_public",net,pgsodium,"pgsodium\\_masks",pgtle,repack,tiger,"tiger\\_data","timescaledb\\_%","\\_timescaledb\\_%",topology,vault}') ORDER BY schema_name`).
 			ReplyError(pgerrcode.DuplicateTable, `relation "test" already exists`)
 		// Run test
 		err := RunMigra(context.Background(), []string{}, "", dbConfig, fsys, conn.Intercept)
Repository: supabase/cli
Pull request #1207 (2023-06-13 03:55:50)

fix: pg_prove installation script for ubuntu
## What kind of change does this PR introduce?

Bug fix https://github.com/supabase/cli/issues/1206

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.



Patch:
diff --git a/internal/utils/docker.go b/internal/utils/docker.go
index bfc3e69c..c646a996 100644
--- a/internal/utils/docker.go
+++ b/internal/utils/docker.go
@@ -360,15 +360,16 @@ func DockerExecOnce(ctx context.Context, container string, env []string, cmd []s
 		stderr = os.Stderr
 	}
 	var out bytes.Buffer
-	err := DockerExecOnceWithStream(ctx, container, env, cmd, &out, stderr)
+	err := DockerExecOnceWithStream(ctx, container, "", env, cmd, &out, stderr)
 	return out.String(), err
 }
 
-func DockerExecOnceWithStream(ctx context.Context, container string, env, cmd []string, stdout, stderr io.Writer) error {
+func DockerExecOnceWithStream(ctx context.Context, container, workdir string, env, cmd []string, stdout, stderr io.Writer) error {
 	// Reset shadow database
 	exec, err := Docker.ContainerExecCreate(ctx, container, types.ExecConfig{
 		Env:          env,
 		Cmd:          cmd,
+		WorkingDir:   workdir,
 		AttachStderr: true,
 		AttachStdout: true,
 	})


Test patch:
diff --git a/internal/db/test/templates/test.sh b/internal/db/test/templates/test.sh
index 340f9ee6..35fc5aa2 100755
--- a/internal/db/test/templates/test.sh
+++ b/internal/db/test/templates/test.sh
@@ -4,7 +4,8 @@ set -euo pipefail
 # TODO: move this dependency to base image
 if ! command -v pg_prove &> /dev/null; then
     apt-get -qq update
-    apt-get -qq install postgresql-14-pgtap &> /dev/null
+    apt-get -qq install make &> /dev/null
+    echo | cpan -T TAP::Parser::SourceHandler::pgTAP &> /dev/null
 fi
 
 # temporarily enable pgtap
diff --git a/internal/db/test/test.go b/internal/db/test/test.go
index 5e8be720..a1e083f6 100644
--- a/internal/db/test/test.go
+++ b/internal/db/test/test.go
@@ -7,7 +7,6 @@ import (
 	_ "embed"
 	"io"
 	"os"
-	"path"
 	"path/filepath"
 
 	"github.com/docker/docker/api/types"
@@ -44,13 +43,11 @@ func pgProve(ctx context.Context, dstPath string, fsys afero.Fs) error {
 	if err := utils.Docker.CopyToContainer(ctx, utils.DbId, dstPath, &buf, types.CopyToContainerOptions{}); err != nil {
 		return err
 	}
-
 	// Passing in script string means command line args must be set manually, ie. "$@"
-	testsPath := path.Join(filepath.Dir(utils.DbTestsDir), filepath.Base(utils.DbTestsDir))
-	args := "cd " + dstPath + ";set -- " + testsPath + ";"
+	args := "set -- " + filepath.ToSlash(utils.DbTestsDir) + ";"
 	// Requires unix path inside container
 	cmd := []string{"/bin/bash", "-c", args + testScript}
-	return utils.DockerExecOnceWithStream(ctx, utils.DbId, nil, cmd, os.Stdout, os.Stderr)
+	return utils.DockerExecOnceWithStream(ctx, utils.DbId, dstPath, nil, cmd, os.Stdout, os.Stderr)
 }
 
 // Ref 1: https://medium.com/@skdomino/taring-untaring-files-in-go-6b07cf56bc07
Repository: supabase/cli
Pull request #1216 (2023-06-16 16:54:49)

chore: add spinner for stopping containers
## What kind of change does this PR introduce?

https://www.notion.so/supabase/Show-a-spinner-when-running-supabase-stop-27519c4405644d3c8cdbd6b6cd43aeae?pvs=4

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.



Patch:
diff --git a/internal/stop/stop.go b/internal/stop/stop.go
index 01905739..3f6868fb 100644
--- a/internal/stop/stop.go
+++ b/internal/stop/stop.go
@@ -4,6 +4,7 @@ import (
 	"context"
 	_ "embed"
 	"fmt"
+	"io"
 	"os"
 
 	"github.com/docker/docker/api/types"
@@ -19,7 +20,10 @@ func Run(ctx context.Context, backup bool, fsys afero.Fs) error {
 	}
 
 	// Stop all services
-	if err := stop(ctx, backup); err != nil {
+	if err := utils.RunProgram(ctx, func(p utils.Program, ctx context.Context) error {
+		w := utils.StatusWriter{Program: p}
+		return stop(ctx, backup, w)
+	}); err != nil {
 		return err
 	}
 
@@ -27,7 +31,7 @@ func Run(ctx context.Context, backup bool, fsys afero.Fs) error {
 	return nil
 }
 
-func stop(ctx context.Context, backup bool) error {
+func stop(ctx context.Context, backup bool, w io.Writer) error {
 	args := filters.NewArgs(
 		filters.Arg("label", "com.supabase.cli.project="+utils.Config.ProjectId),
 	)
@@ -45,6 +49,7 @@ func stop(ctx context.Context, backup bool) error {
 			ids = append(ids, c.ID)
 		}
 	}
+	fmt.Fprintln(w, "Stopping containers...")
 	utils.WaitAll(ids, utils.DockerStop)
 	if _, err := utils.Docker.ContainersPrune(ctx, args); err != nil {
 		return err


Test patch:
diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go
index 1ad1e828..13d4d7b1 100644
--- a/internal/stop/stop_test.go
+++ b/internal/stop/stop_test.go
@@ -3,6 +3,7 @@ package stop
 import (
 	"context"
 	"errors"
+	"io"
 	"net/http"
 	"os"
 	"testing"
@@ -92,7 +93,7 @@ func TestStopServices(t *testing.T) {
 			Reply(http.StatusOK).
 			JSON(types.NetworksPruneReport{})
 		// Run test
-		err := stop(context.Background(), true)
+		err := stop(context.Background(), true, io.Discard)
 		// Check error
 		assert.NoError(t, err)
 		assert.Empty(t, apitest.ListUnmatchedRequests())
@@ -131,7 +132,7 @@ func TestStopServices(t *testing.T) {
 			Reply(http.StatusOK).
 			JSON(types.NetworksPruneReport{})
 		// Run test
-		err := stop(context.Background(), false)
+		err := stop(context.Background(), false, io.Discard)
 		// Check error
 		assert.NoError(t, err)
 		assert.Empty(t, apitest.ListUnmatchedRequests())
@@ -149,7 +150,7 @@ func TestStopServices(t *testing.T) {
 			Post("/v" + utils.Docker.ClientVersion() + "/containers/prune").
 			ReplyError(errors.New("network error"))
 		// Run test
-		err := stop(context.Background(), true)
+		err := stop(context.Background(), true, io.Discard)
 		// Check error
 		assert.ErrorContains(t, err, "network error")
 		assert.Empty(t, apitest.ListUnmatchedRequests())