Common Errors Encountered When Using user-scanner: A Complete Troubleshooting Guide
The user-scanner library reports all failures through the Result object, using Result.error() to capture network issues, timeouts, HTTP anomalies, and validation failures while normalizing messages via the humanize_exception method in user_scanner/core/result.py.
When automating username and email verification across social platforms, understanding failure modes is critical for building robust automation pipelines. The open-source kaifcodec/user-scanner project centralizes error handling through a unified Result class that normalizes exceptions into actionable, human-readable feedback. Unlike libraries that crash on connectivity issues, user-scanner categorizes failures systematically—helping you decide whether to retry, switch VPNs, or report platform changes.
How user-scanner Normalizes Error Reporting
The architecture deliberately avoids raising exceptions for expected failure modes. Instead, the Orchestrator class in user_scanner/core/orchestrator.py returns a Result object for every scan operation. This object contains a Status enum and a reason string populated by either the validator module or the humanize_exception utility.
In user_scanner/core/result.py, the Result class provides the humanize_exception() static method, which maps low-level Python socket errors and HTTP library exceptions into clear messages like "Network unreachable (Is your internet on?)" or "Could not resolve hostname". This normalization ensures that validators across user_scanner/user_scan/social/ and user_scanner/email_scan/ trees return consistent error formats without interrupting batch processing workflows.
The 7 Common Error Categories in user-scanner
Analysis of the validator modules—including instagram.py, facebook.py, and tiktok.py—reveals seven distinct failure patterns captured by the Result system.
Network and DNS Resolution Failures
These occur when the host machine lacks internet connectivity, DNS resolution fails, or the remote server drops the connection unexpectedly. The humanize_exception method intercepts underlying socket errors and returns messages such as "Connection closed by remote server" or "Network unreachable". These errors originate from the transport layer before HTTP headers are exchanged.
Connection Timeouts
Slow sites or region-blocked services trigger timeout errors. When the request duration exceeds the threshold defined in ScanConfig (located in user_scanner/core/helpers.py), the system returns "Connection timed out (try a VPN if the site is blocked in your region)". This category is distinct from DNS failures because the TCP handshake may succeed before the application layer stalls.
Unexpected HTTP Status Codes
Modern platforms frequently return non-200 status codes for valid requests. Validators report errors like "Unexpected status: 503" for service outages or "HTTP 429" when encountering rate limiting. The facebook.py module specifically detects "Rate limited by Facebook" states, while other social validators identify Cloudflare challenges that block automated access.
Malformed or Missing Payloads
When a site returns HTML or JSON that lacks expected profile markers, validators return payload mismatch errors. Messages like "Profile payload does not match the requested handle" or "Unexpected response body, report it via GitHub issues" indicate that the platform's DOM structure has changed, requiring updates to the CSS selectors or JSON paths hardcoded in modules such as user_scanner/user_scan/social/instagram.py.
Input Validation Errors
Before making network requests, individual modules enforce platform-specific username conventions. For example, user_scanner/user_scan/social/tiktok.py returns "Length must be 2-24 characters" for invalid handles, while Facebook validators emit "Only letters, numbers and periods allowed" when encountering usernames containing prohibited characters. These errors prevent unnecessary HTTP traffic for obviously invalid inputs.
Rate Limiting and Bot Detection
Services employing aggressive bot protection (such as Twitter/X or Instagram) trigger blocks detectable by impersonate_validate or curl_cffi wrappers. Error messages include "Twitter rate limit or blocked" or generic "Unexpected response body" when fingerprint randomization fails to bypass Cloudflare or DataDome challenges. These indicate the IP address or request signature has been flagged.
Unexpected Python Exceptions
Any uncaught exceptions from underlying HTTP libraries bubble up through Result.error() wrappers throughout the codebase. These appear as Result.error(Exception("Error 11001")) or similar, indicating potential library incompatibilities, SSL certificate validation failures, or bugs in the validator logic that require debugging beyond standard network troubleshooting.
Implementing Error Handling in Practice
The following patterns demonstrate how to process these errors using the Orchestrator class and Result API.
Checking for Errors After a Scan
from user_scanner.core.result import Result
from user_scanner.core.orchestrator import Orchestrator
# Initialize the orchestrator
orchestrator = Orchestrator()
# Execute a scan
outcome: Result = orchestrator.scan_username("nonexistent_user", site="github")
# Check status and retrieve human-readable reason
if outcome.status == Result.Status.ERROR:
print("⚠️ Scan failed:", outcome.get_reason())
# Access the problematic URL if available
if outcome.url:
print("🔗 URL that caused the error:", outcome.url)
Handling Network-Specific Failures
# Network errors return Result objects rather than raising exceptions
result = orchestrator.scan_email("someone@example.com", site="gmail")
if result.status == Result.Status.ERROR:
reason = result.get_reason()
if "timed out" in reason or "VPN" in reason:
print("✘ Connection issue - consider using a VPN:", reason)
elif "resolve" in reason:
print("✘ DNS failure detected:", reason)
else:
print("✘ Unexpected error:", reason)
Using Console Output Helpers
from user_scanner.core.helpers import ScanConfig
# Configure output format (hides URLs by default)
config = ScanConfig()
# Get color-coded string for terminal display
print(result.get_console_output(config))
# Output: [✔] Found … info: smth (or error variant)
Summary
- The
Resultclass inuser_scanner/core/result.pyserves as the central error reporting mechanism, utilizingResult.error()andhumanize_exception()to standardize failure messages. - Seven distinct error categories cover network connectivity, timeouts, HTTP status anomalies, payload structure mismatches, input validation failures, platform rate limiting, and uncaught Python exceptions.
- Validators across
user_scanner/user_scan/social/returnResultobjects rather than raising exceptions, ensuring batch operations complete without pipeline interruptions. - Error messages frequently include remediation hints, such as VPN recommendations for regional blocks or GitHub issue prompts for payload mismatches.
- The
Orchestratoraggregates results whileScanConfigcontrols timeout and concurrency parameters that directly influence the frequency of timeout-related errors.
Frequently Asked Questions
Why does user-scanner return errors instead of raising exceptions?
The Orchestrator design treats scan failures as expected outcomes rather than fatal crashes. By returning Result.error() objects, the library allows batch operations to continue processing remaining targets even when individual sites fail. This approach prevents a single unresponsive platform from crashing the entire validation pipeline, preserving throughput during large-scale scans.
How can I distinguish between a network error and a platform block?
Examine the string returned by result.get_reason(). Network errors (DNS, timeouts) originate from humanize_exception() in user_scanner/core/result.py and mention connectivity issues like "Could not resolve hostname". Platform blocks contain service-specific identifiers such as "Rate limited by Facebook" or HTTP status codes like "Unexpected status: 503" generated by validators in the social modules.
What should I do when encountering "Unexpected response body" errors?
This error—emitted by validators like those in user_scanner/user_scan/social/instagram.py—indicates the platform's HTML structure or API response format has changed. Update to the latest user-scanner version first. If the error persists, report the issue via GitHub with the specific site and username that triggered the failure, as the validator likely requires updated CSS selectors or JSON parsing logic.
Can I customize timeout thresholds to reduce connection errors?
Yes. Import ScanConfig from user_scanner/core/helpers.py and instantiate it with modified timeout values before passing it to the Orchestrator. Increasing the timeout parameter helps with slow international connections or heavily loaded sites, though this trade-off increases the total duration of batch scanning operations.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →