Skip to content

Commit 588c0c1

Browse files
committed
feat: wrap user environment errors with UntrackedError
Wrap the following errors to exclude them from Sentry: - ErrDocker: docker not running or inaccessible - ErrPort: port already in use - ErrAirbyteDir: airbyte directory inaccessible - ErrIpAddressForHostFlag: invalid host flag (IP address) - ErrInvalidHostFlag: invalid host flag format - cannot read PG_VERSION file (excluding not found)
1 parent 0bdfcd3 commit 588c0c1

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

internal/cmd/local/check.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ func dockerInstalled(ctx context.Context, telClient telemetry.Client) (docker.Ve
3535
if dockerClient == nil {
3636
if dockerClient, err = docker.New(ctx); err != nil {
3737
pterm.Error.Println("Unable to create Docker client")
38-
return docker.Version{}, fmt.Errorf("%w: unable to create client: %w", abctl.ErrDocker, err)
38+
return docker.Version{}, abctl.NewUntrackedError(
39+
fmt.Errorf("%w: unable to create client: %w", abctl.ErrDocker, err),
40+
)
3941
}
4042
}
4143

4244
version, err := dockerClient.Version(ctx)
4345
if err != nil {
4446
pterm.Error.Println("Unable to communicate with the Docker daemon")
45-
return docker.Version{}, fmt.Errorf("%w: %w", abctl.ErrDocker, err)
47+
return docker.Version{}, abctl.NewUntrackedError(
48+
fmt.Errorf("%w: %w", abctl.ErrDocker, err),
49+
)
4650
}
4751

4852
span.SetAttributes(
@@ -94,10 +98,14 @@ func portAvailable(ctx context.Context, port int) error {
9498
lc := &net.ListenConfig{}
9599
listener, err := lc.Listen(ctx, "tcp", fmt.Sprintf("localhost:%d", port))
96100
if isErrorAddressAlreadyInUse(err) {
97-
return fmt.Errorf("%w: port %d is already in use", abctl.ErrPort, port)
101+
return abctl.NewUntrackedError(
102+
fmt.Errorf("%w: port %d is already in use", abctl.ErrPort, port),
103+
)
98104
}
99105
if err != nil {
100-
return fmt.Errorf("%w: unable to determine if port '%d' is available: %w", abctl.ErrPort, port, err)
106+
return abctl.NewUntrackedError(
107+
fmt.Errorf("%w: unable to determine if port '%d' is available: %w", abctl.ErrPort, port, err),
108+
)
101109
}
102110
// if we're able to bind to the port (and then release it), it should be available
103111
defer func() {
@@ -193,10 +201,10 @@ func (e InvalidPortError) Error() string {
193201

194202
func validateHostFlag(host string) error {
195203
if ip := net.ParseIP(host); ip != nil {
196-
return abctl.ErrIpAddressForHostFlag
204+
return abctl.NewUntrackedError(abctl.ErrIpAddressForHostFlag)
197205
}
198206
if !regexp.MustCompile(`^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\.[a-z0-9](?:[-a-z0-9]*[a-z0-9])?)*$`).MatchString(host) {
199-
return abctl.ErrInvalidHostFlag
207+
return abctl.NewUntrackedError(abctl.ErrInvalidHostFlag)
200208
}
201209
return nil
202210
}

internal/cmd/local/local.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ func (c *Cmd) BeforeApply() error {
2727
}
2828

2929
if err := checkAirbyteDir(); err != nil {
30-
return fmt.Errorf("%w: %w", abctl.ErrAirbyteDir, err)
30+
return abctl.NewUntrackedError(
31+
fmt.Errorf("%w: %w", abctl.ErrAirbyteDir, err),
32+
)
3133
}
3234

3335
return nil

internal/docker/docker.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ func newWithOptions(ctx context.Context, newPing newPing, goos string) (*Docker,
148148
}
149149
}
150150

151-
return nil, fmt.Errorf("%w: unable to create docker client", abctl.ErrDocker)
151+
return nil, abctl.NewUntrackedError(
152+
fmt.Errorf("%w: unable to create docker client", abctl.ErrDocker),
153+
)
152154
}
153155

154156
// createAndPing attempts to create a docker client and ping it to ensure we can communicate

internal/service/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func EnablePsql17() (bool, error) {
241241

242242
pgVersion, err := pgData.Version()
243243
if err != nil && !errors.Is(err, fs.ErrNotExist) {
244-
return false, fmt.Errorf("failed to determine if any previous psql version exists: %w", err)
244+
return false, abctl.NewUntrackedError(fmt.Errorf("failed to determine if any previous psql version exists: %w", err))
245245
}
246246

247247
if pgVersion == "" || pgVersion == "17" {

0 commit comments

Comments
 (0)