dagger/dagger · error · httpError

e.Error()

Error message

e.Error()

What it means

This is the httpError type's Error() used when writing an HTTP error response: http.Error(w, e.Error(), e.code). The reported error text is simply the message of an httpError produced by the server's HTTP handler when a wrapped error carries an explicit HTTP status code.

Source

Thrown at engine/server/session.go:3030

func (srv *Server) EngineVolumeState() core.EngineVolumeState {
	return core.EngineVolumeState{
		RootDir:                    srv.rootDir,
		RecursiveReadOnlySupported: srv.recursiveReadOnlyMounts,
	}
}

type httpError struct {
	error
	code int
}

func httpErr(err error, code int) httpError {
	return httpError{err, code}
}

func (e httpError) WriteTo(w http.ResponseWriter) {
	http.Error(w, e.Error(), e.code)
}

type gqlError struct {
	error
	httpCode int
}

func gqlErr(err error, httpCode int) gqlError {
	return gqlError{err, httpCode}
}

func (e gqlError) WriteTo(w http.ResponseWriter) {
	gqlerr := &gqlerror.Error{
		Err:     e.error,
		Message: e.Error(),
	}
	res := graphql.Response{
		Errors: gqlerror.List{gqlerr},

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Inspect the HTTP status code and message body returned by the engine endpoint
  2. Look upstream for the original error that was converted via httpErr(err, code)
  3. Fix the underlying condition that caused the handler to return the error
Defensive patterns

Strategy: try-catch

Validate before calling

if resp.StatusCode >= 400 { /* body carries httpError text */ }

Try / catch

if resp.StatusCode != 200 {
	body, _ := io.ReadAll(resp.Body)
	return fmt.Errorf("engine http %d: %s", resp.StatusCode, body)
}

Prevention

When it happens

Trigger: A handler wrapped by httpHandlerFunc returns an error that errors.As matches to httpError; WriteTo emits it with the configured code.

Common situations: Client sees a plain-text HTTP error body (e.g. 4xx/5xx) from the engine's session HTTP endpoint; server-side failures surfaced through the error-returning handler path.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/b96c364e196fb72a. Report an issue: GitHub.