JuliusBrussee/caveman · error

awssig: request has no URL

Error message

awssig: request has no URL

What it means

Sign was given an http.Request with a nil URL, so there is no host, path, or query to build the SigV4 canonical request from. The caller constructed the request improperly (e.g. http.NewRequest failed and the error was ignored) — a precondition check before any cryptographic work.

Source

Thrown at shared/platform/awssig/awssig.go:73

// the Authorization, X-Amz-Date, X-Amz-Content-Sha256 (and, when present,
// X-Amz-Security-Token) headers on req. The Host header is derived from req.URL.
//
// payloadHash is the lowercase hex SHA-256 of the request body; pass
// HashPayload(body) for the common case, or UnsignedPayload() for streaming
// bodies that must not be buffered. now fixes the signing instant (use
// time.Now().UTC()); it is a parameter so tests are deterministic.
//
// Sign returns an error only for malformed inputs (no region/service, missing
// credentials, unparseable URL). It never returns the secret in the error.
func (s Signer) Sign(req *http.Request, creds Credentials, payloadHash string, now time.Time) error {
	if s.Region == "" || s.Service == "" {
		return fmt.Errorf("awssig: signer requires region and service")
	}
	if !creds.Valid() {
		return fmt.Errorf("awssig: incomplete AWS credentials")
	}
	if req.URL == nil {
		return fmt.Errorf("awssig: request has no URL")
	}
	now = now.UTC()
	amzDate := now.Format("20060102T150405Z")
	dateStamp := now.Format("20060102")

	host := req.URL.Host
	if req.Host != "" {
		host = req.Host
	}
	req.Header.Set("Host", host)
	req.Header.Set("X-Amz-Date", amzDate)
	req.Header.Set("X-Amz-Content-Sha256", payloadHash)
	if creds.SessionToken != "" {
		req.Header.Set("X-Amz-Security-Token", creds.SessionToken)
	}

	canonicalHeaders, signedHeaders := canonicalHeaderSet(req, host)
	canonicalRequest := strings.Join([]string{

View on GitHub (pinned to 766dce6b13)

Solutions

  1. Build the request with a valid URL before passing it to Sign
  2. Check and handle http.NewRequest errors instead of proceeding with a nil URL
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shared/platform/awssig/awssig.go:73 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/45d4397bbeefabef. Report an issue: GitHub.