The Philosophy of AI SAFE²: If the system fails, it must Fail-Closed. It is better to show an error message than to leak a secret or execute a malicious prompt.
Symptom: The scanner.py or detect-secrets tool flags a random string as an API key (e.g., a long CSS hash or a UUID).
Cause: The scanner looks for “High Entropy Strings” (randomness).
Fix:
.secrets.baseline file.# Safe: CSS Hash).pip install FailsSymptom: ModuleNotFoundError: No module named 'detect_secrets'
Cause: You are likely in the wrong virtual environment or missing the package.
Fix:
pip install detect-secrets pyyaml
# If that fails, try:
python3 -m pip install detect-secrets pyyaml
localhost:8000)Symptom: Your Python script or Agent fails with ConnectionRefusedError when trying to talk to the Gateway.
Cause: The Docker container is not running, or ports are not mapped.
Fix:
docker ps. Is ai-safe-gateway listed?-p?
docker run ai-safe-gatewaydocker run -p 8000:8000 ai-safe-gatewaySymptom: You send a normal request like “Help me design a system,” but get: Security Policy Violation: Blocked Pattern.
Cause: The Regex rules in default.yaml are too aggressive for your specific use case.
Fix:
system is blocking “system design,” change the regex from system to system: (looking for the prompt injection syntax specifically).# Allow 10 failures before breaking
api_breaker = pybreaker.CircuitBreaker(fail_max=10, reset_timeout=60)
Symptom: InvalidRequestError: This model's maximum context length is 8192 tokens...
Cause: You are not sanitizing input length. Users (or loops) are sending too much text.
Fix:
InputValidator class to truncate input before sending it.
if len(user_input) > 2000:
user_input = user_input[:2000] # Truncate