JuliusBrussee/caveman · error
kms: create %s request: %w
Error message
kms: create %s request: %w
What it means
Client.call wraps the http.NewRequestWithContext failure while building the POST request for a KMS operation. This fires when the constructed endpoint URL (apiBaseURL + region/key path segments) cannot be parsed by http.NewRequestWithContext — typically an invalid API base URL or control characters in region/keyID that survived validation.
Source
Thrown at shared/platform/kms/kms.go:355
if !regionPattern.MatchString(region) {
return errors.New("kms: invalid Scaleway region")
}
if !keyIDPattern.MatchString(keyID) {
return errors.New("kms: invalid Scaleway key ID")
}
return nil
}
func (c *Client) call(ctx context.Context, region, keyID, operation string, input, output any) error {
body, err := json.Marshal(input)
if err != nil {
return fmt.Errorf("kms: encode %s request: %w", operation, err)
}
endpoint := c.apiBaseURL + "/key-manager/v1alpha1/regions/" + url.PathEscape(region) +
"/keys/" + url.PathEscape(keyID) + "/" + operation
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(body))
if err != nil {
return fmt.Errorf("kms: create %s request: %w", operation, err)
}
req.Header.Set("content-type", "application/json")
req.Header.Set("accept", "application/json")
req.Header.Set("x-auth-token", c.token)
resp, err := c.httpClient.Do(req)
if err != nil {
return fmt.Errorf("kms: %s request failed: %w", operation, err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
_, _ = io.Copy(io.Discard, io.LimitReader(resp.Body, 32<<10))
return fmt.Errorf("kms: %s returned HTTP %d", operation, resp.StatusCode)
}
data, err := io.ReadAll(io.LimitReader(resp.Body, maxResponseBytes+1))
if err != nil {
return fmt.Errorf("kms: read %s response: %w", operation, err)
}
if len(data) > maxResponseBytes {View on GitHub (pinned to 766dce6b13)
Solutions
- Check the configured API base URL for invalid characters or formatting
- Verify region/keyID values are the validated Scaleway formats
- If the base URL is custom, ensure it is a well-formed absolute HTTP(S) URL
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/platform/kms/kms.go:355 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/53e7ec0bebbacc2f.
Report an issue: GitHub.