• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 15104611350

19 May 2025 04:53AM UTC coverage: 60.212% (-0.03%) from 60.242%
15104611350

push

github

web-flow
fix: convert timeout fields to string (#3582)

fix: timeout must be typed as string

0 of 4 new or added lines in 1 file covered. (0.0%)

4 existing lines in 2 files now uncovered.

9024 of 14987 relevant lines covered (60.21%)

509.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/postgresConfig/update/update.go
1
package update
2

3
import (
4
        "bytes"
5
        "context"
6
        "encoding/json"
7
        "fmt"
8
        "strconv"
9
        "strings"
10

11
        "github.com/go-errors/errors"
12
        "github.com/spf13/afero"
13
        "github.com/supabase/cli/internal/postgresConfig/get"
14
        "github.com/supabase/cli/internal/utils"
15
)
16

17
func Run(ctx context.Context, projectRef string, values []string, replaceOverrides, noRestart bool, fsys afero.Fs) error {
×
18
        // 1. Prepare config overrides
×
19
        newConfigOverrides := make(map[string]string)
×
20
        for _, config := range values {
×
21
                splits := strings.Split(config, "=")
×
22
                if len(splits) != 2 {
×
23
                        return errors.Errorf("expected config value in key:value format, received: '%s'", config)
×
24
                }
×
25
                newConfigOverrides[splits[0]] = splits[1]
×
26
        }
27
        // 2. If not in replace mode, retrieve current overrides
28
        finalOverrides := make(map[string]interface{})
×
29
        {
×
30
                if !replaceOverrides {
×
31
                        config, err := get.GetCurrentPostgresConfig(ctx, projectRef)
×
32
                        if err != nil {
×
33
                                return err
×
34
                        }
×
35
                        finalOverrides = config
×
36
                }
37
        }
38
        // 3. Create the list of final overrides
39
        {
×
40
                for k, v := range newConfigOverrides {
×
41
                        // this is hacky - if we're able to convert the value to an integer, we do so
×
42
                        // if we start supporting config fields with e.g. floating pt overrides this'll need to be updated
×
43
                        if vInt, err := strconv.Atoi(v); err == nil {
×
44
                                finalOverrides[k] = vInt
×
45
                        } else if vBool, err := strconv.ParseBool(v); err == nil {
×
46
                                finalOverrides[k] = vBool
×
47
                        } else {
×
48
                                finalOverrides[k] = v
×
49
                        }
×
50
                }
51
        }
52
        // 4. update config overrides and print out final result
53
        {
×
54
                if noRestart {
×
55
                        finalOverrides["restart_database"] = false
×
56
                }
×
57
                // statement_timeout and wal_sender_timeout must be typed as string
NEW
58
                for k, v := range finalOverrides {
×
NEW
59
                        if _, ok := v.(string); strings.HasSuffix(k, "_timeout") && !ok {
×
NEW
60
                                finalOverrides[k] = fmt.Sprintf("%v", v)
×
NEW
61
                        }
×
62
                }
63
                bts, err := json.Marshal(finalOverrides)
×
64
                if err != nil {
×
65
                        return errors.Errorf("failed to serialize config overrides: %w", err)
×
66
                }
×
67
                resp, err := utils.GetSupabase().V1UpdatePostgresConfigWithBodyWithResponse(ctx, projectRef, "application/json", bytes.NewReader(bts))
×
68
                if err != nil {
×
69
                        return errors.Errorf("failed to update config overrides: %w", err)
×
70
                }
×
71
                if resp.JSON200 == nil {
×
72
                        if resp.StatusCode() == 400 {
×
73
                                return errors.Errorf("failed to update config overrides: %s (%s). This usually indicates that an unsupported or invalid config override was attempted. Please refer to https://supabase.com/docs/guides/platform/custom-postgres-config", resp.Status(), string(resp.Body))
×
74
                        }
×
75
                        return errors.Errorf("failed to update config overrides: %s (%s)", resp.Status(), string(resp.Body))
×
76
                }
77
        }
78
        return get.Run(ctx, projectRef, fsys)
×
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc