Fix: Update Instagram detection logic#2903
Conversation
Automatic validation of changes
Failures were detected on at least one updated target. Commits containing accuracy failures will often not be merged (unless a rationale is provided, such as false negatives due to regional differences). |
| ], | ||
| "errorType": "message", | ||
| "headers": { | ||
| "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1" |
There was a problem hiding this comment.
Interesting fix! We can try using a new UA since the current one is from 2021 and Instagram may deprioritise or block requests from severely outdated mobile browsers.
There was a problem hiding this comment.
Thanks for the suggestion. I've updated the User-Agent to a recent iOS/Safari version and pushed the changes to this PR.
I also re-tested the detection locally to confirm that existing and non-existent Instagram profiles are still distinguished correctly. Please let me know if you'd like me to test against any additional scenarios.
This PR fixes the broken Instagram detection which was causing false negatives (existing accounts reported as "Not Found").
Problem
Proxy Blocked: The previous implementation relied on imginn.com, which is currently returning a 403 (Cloudflare challenge) for automated requests.
Soft 404s: Direct probes to instagram.com return a 200 OK status for both existing and non-existing accounts.
UA Sensitivity: Standard desktop User-Agents often lead to a generic login wall, making it impossible to differentiate account existence via HTTP headers.
Solution
Switched to Message Detection: Changed errorType from status_code to message.
Mobile User-Agent: Updated headers to use a Mobile (iPhone) User-Agent. My testing confirmed that Instagram serves unique <title> tags for existing profiles when queried with a mobile UA, even without a session.
Error Patterns: Added detection patterns for non-existent profiles:
Verification Results
Tested locally with the --local flag: