JuliusBrussee/caveman · error
native session marker: invalid key or session id
Error message
native session marker: invalid key or session id
What it means
SessionMarker validated its inputs before building the signed correlation marker and found the session key unusable (nil/wrong length) or the session id invalid (empty/too long/bad characters). Markers are HMAC-protected, so malformed inputs are refused outright.
Source
Thrown at proxy/internal/nativeruntime/marker.go:73
}
key, err = os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("native session key read: %w", err)
}
if len(key) != sessionKeyBytes {
return nil, fmt.Errorf("native session key length = %d, want %d", len(key), sessionKeyBytes)
}
if err := os.Chmod(path, 0o600); err != nil {
return nil, fmt.Errorf("native session key chmod: %w", err)
}
return key, nil
}
// SessionMarker builds model-temporary correlation context. Local proxy removes
// valid markers byte-surgically before provider inspection or forwarding.
func SessionMarker(key []byte, sessionID string) (string, error) {
if len(key) != sessionKeyBytes || sessionID == "" || len(sessionID) > 256 {
return "", errors.New("native session marker: invalid key or session id")
}
encoded := base64.RawURLEncoding.EncodeToString([]byte(sessionID))
sig := markerMAC(key, encoded)
return fmt.Sprintf(`[[caveman-session-v1 sid="%s" sig="%s"]]`, encoded, sig), nil
}
// StripSessionMarkers removes only valid HMAC-signed markers. Invalid marker-
// shaped user text remains byte-identical. Conflicting valid session IDs are
// stripped but return no correlation identity.
func StripSessionMarkers(body, key []byte) (stripped []byte, sessionID string, changed bool) {
if len(key) != sessionKeyBytes {
return body, "", false
}
matches := markerPattern.FindAllSubmatchIndex(body, -1)
if len(matches) == 0 {
return body, "", false
}
out := make([]byte, 0, len(body))View on GitHub (pinned to 766dce6b13)
Solutions
- Load the session key via the runtime helper that enforces the 32-byte length
- Pass a non-empty, identity-safe session id
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at proxy/internal/nativeruntime/marker.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/79c402e4fc56b1c8.
Report an issue: GitHub.