JuliusBrussee/caveman · error
awssig: incomplete AWS credentials
Error message
awssig: incomplete AWS credentials
What it means
Signer.Sign calls creds.Valid() and rejects signing when the Credentials are incomplete (empty access key ID, secret, or other required fields per Valid()). This prevents producing signatures with zero-valued material. Per the library docs, the error never includes the secret.
Solutions
- Call creds.Valid() yourself before Sign to get an earlier, clearer failure point and log which field is missing (without printing secrets).
- Ensure the credentials were actually loaded: check AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (and session token) are populated.
- Check the awscreds Provider error path: if Credentials(ctx) returned an error, don't proceed with its zero-value result.
- Fix struct construction so all credential fields are assigned.
Example fix
// before
err := signer.Sign(req, creds, payloadHash, now) // creds partially populated
// after
if !creds.Valid() {
return errors.New("refusing to sign: credentials not loaded")
}
err := signer.Sign(req, creds, payloadHash, now) Defensive patterns
Strategy: validation
Validate before calling
if !creds.Valid() {
return errors.New("cannot sign: AWS credentials not loaded (check AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY or metadata provider)")
} Try / catch
if err := signer.Sign(req, creds, hash, now); err != nil {
if strings.Contains(err.Error(), "incomplete AWS credentials") {
return fmt.Errorf("credential load failed upstream: %w", err)
}
return err
} Prevention
- Never use the zero-value Credentials struct; load credentials through the awscreds Provider and propagate its errors.
- Call creds.Valid() before every Sign call in wrappers.
- Never log credentials when diagnosing; check only presence/non-empty.
When it happens
Trigger: Calling Sign with awssig.Credentials{} or one where AccessKeyID/SecretAccessKey (or SessionToken when required by Valid) is empty; credentials loaded from awscreds failed silently upstream and zero values were passed through.
Common situations: Environment variables AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY unset; a failed metadata credential fetch whose empty result was used anyway; struct literal initialization missing fields.
Related errors
- bedrock: missing AWS credentials in x-cave-upstream-key
- ErrSigV4Configuration
- AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set…
- awscreds: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must…
- awscreds: build container credentials request
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/a8fa8c222c4f2f1c.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/awssig/awssig.go:71
}
// Sign computes the SigV4 signature for req against the given payload and sets
// 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)
}View on GitHub (pinned to 3ee70a1026)