Troubleshooting Sanad
What the SDK's diagnostics codes mean, and how to fix common integration problems.
Every Sanad SDK has a diagnostics() call that returns the SDK's state, its sessionId, the lastError and the sdkVersion. It holds codes only, never device data or credentials, so it's safe to log and to attach to a support ticket. Include sdkVersion whenever you contact Lean.
The codes are the same on Android, iOS and web. Android writes the states in capitals (ACTIVE), and iOS and web in lower case (active).
SDK states
| State | Meaning |
|---|---|
IDLE | No session: init hasn't been called yet, or it failed in a way you can retry |
OPENING | init is opening the session |
ACTIVE | A session is open, and collect() works |
STOPPED | Lean refused the key or the app. It lasts until the app restarts or the page reloads |
RESETTING | Reserved for a future release |
SDK errors
lastError | What happened | What to do |
|---|---|---|
invalid_sdk_key | Lean doesn't know the SDK key | Check the key, and that it matches the build's environment, sandbox or production |
forbidden | Lean refused the app or this device | Check that Sanad is enabled for your application. During development, clearing the app's or the site's data helps after switching between applications or environments |
network | Lean couldn't be reached | Check the connection, and that no proxy, firewall or Content Security Policy blocks Lean's host. You can call init again |
rate_limited | Lean asked the SDK to slow down | Nothing: the SDK backs off on its own |
server_error | A temporary problem on Lean's side | Nothing: the SDK retries on its own |
bad_response, malformed, too_large | A request or response was invalid | Contact Lean with the sdkVersion |
key_unavailable | The device couldn't create the SDK's key (Android Keystore, iOS Secure Enclave, or the browser's key store) | Rare; there's no session on that device. On iOS, make sure the app is signed |
frame_unavailable | Web only: Lean's frame didn't load within 10 seconds | Check that your Content Security Policy allows sanad.leantech.me in script-src and frame-src, and that the page can reach it. You can call init again |
already_initialised | init was called again with a different key | Use one key per app build |
session_not_found | Lean has no such session for this app | Make sure the key and environment didn't change while the app was running |
envelope_cap | The session already sent 10 sets of signals | Expected if you call collect() very often. Call it before sensitive actions only |
internal | An unexpected error inside the SDK | Contact Lean with the sdkVersion |
Treat a lastError you don't recognise as opaque: log it, and carry on without Sanad.
Backend problems
| Symptom | Cause | What to do |
|---|---|---|
400 invalid_request from /oauth2/token | Wrong client_id or client_secret | Check your credentials in the Application Dashboard |
401 or 403 from the assessment | The token is missing or expired, or wasn't requested with scope=api | Get a new token with scope=api |
404 Session not found | The session belongs to another application or environment | Make sure the SDK key and the client credentials belong to the same application, and are both sandbox or both production |
NO_OBSERVATIONS for more than about 15 seconds | The app opened a session, but no signals reached Lean | Check diagnostics() in your app, and that collectOnInit is on or collect() is called |
The same assessment_id after collect() | The new signals are still being assessed | Ask again every 2 seconds. See Reading assessments |
emulator_detected on your test device | You're testing on an emulator or simulator | Test on a real device |
INSUFFICIENT_DATA in location_analysis | Your app has no location permission, or your user declined it | Nothing: this is expected, and isn't a risk signal by itself |
Updated about 3 hours ago
Did this page help you?
