Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/client-proxy/internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func dnsResolution(sandboxId string, logger *zap.Logger) (string, error) {
// the api server wasn't found, maybe the API server is rolling and the DNS server is not updated yet
if dnsErr != nil || len(resp.Answer) == 0 {
err = dnsErr
logger.Warn(fmt.Sprintf("host for sandbox %s not found: %s", sandboxId, err), zap.Error(err), zap.Int("retry", i+1))
logger.Warn("host for sandbox not found", zap.Error(err), l.WithSandboxID(sandboxId), zap.Int("retry", i+1))

// Jitter
time.Sleep(time.Duration(rand.Intn(10)) * time.Millisecond)
Expand All @@ -76,7 +76,7 @@ func dnsResolution(sandboxId string, logger *zap.Logger) (string, error) {

// there's no answer, we can't proxy the request
if err != nil {
return "", ErrNodeNotFound
return "", fmt.Errorf("failed to resolve sandbox: %w", err)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be fatal error, not just node not found

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: DNS Query Fails Silently, Causing Invalid Proxying

When DNS queries return no answers but no DNS error, the err variable remains nil after retries. This causes the function to return an empty node string with a nil error, incorrectly signaling success. Downstream code may then attempt to proxy to an invalid empty IP.

Fix in Cursor Fix in Web

}

return node, nil
Expand Down
5 changes: 3 additions & 2 deletions packages/shared/pkg/proxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"go.uber.org/zap"

"github.com/e2b-dev/infra/packages/shared/pkg/logger"
"github.com/e2b-dev/infra/packages/shared/pkg/proxy/pool"
"github.com/e2b-dev/infra/packages/shared/pkg/proxy/template"
)
Expand Down Expand Up @@ -60,13 +61,13 @@ func handler(p *pool.ProxyPool, getDestination func(r *http.Request) (*pool.Dest

var notFoundErr *SandboxNotFoundError
if errors.As(err, &notFoundErr) {
zap.L().Warn("sandbox not found", zap.String("host", r.Host))
zap.L().Warn("sandbox not found", zap.String("host", r.Host), logger.WithSandboxID(notFoundErr.SandboxId))

err := template.
NewSandboxNotFoundError(notFoundErr.SandboxId, r.Host).
HandleError(w, r)
if err != nil {
zap.L().Error("failed to handle sandbox not found error", zap.Error(err))
zap.L().Error("failed to handle sandbox not found error", zap.Error(err), logger.WithSandboxID(notFoundErr.SandboxId))
http.Error(w, "Failed to handle sandbox not found error", http.StatusInternalServerError)

return
Expand Down
Loading