Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle "user not found" error pages returning 400 status codes now, r…
…ather than 200
  • Loading branch information
Deer-Spangle committed Dec 11, 2025
commit 256e5622f90845d4746137f71a5da6dfd7fabdc7
14 changes: 13 additions & 1 deletion lib/faexport/scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@
rescue OpenURI::HTTPError => e
$http_errors.increment(labels: { page_type: page_type })
# Detect and handle known errors
if e.io.status[0] == "403" || e.io.status[0] == "503"
if e.io.status[0] == "403" || e.io.status[0] == "503" || e.io.status[0] == "400"
raw = e.io.read
html = Nokogiri::HTML(raw.encode("UTF-8", invalid: :replace, undef: :replace).delete("\000"))

Expand All @@ -1334,6 +1334,18 @@
$slowdown_errors.increment(labels: { page_type: page_type })
raise FASlowdownError.new(url)
end

# Handle user not found errors
if e.io.status[0] == "400"
head = html.xpath("//head//title").first
if head.content == "System Error"
error_msg = html.at_css("table.maintable td.alt1 font").content
# Handle user profile not found, and user not found on journal listing
if error_msg.include?("This user cannot be found") || error_msg.include?("User not found!")
raise FANoUserError.new(url)
end
end
end
end
# Retry some types of error
if e.io.status[0] == "502" || e.io.status[0] == "520"
Expand Down
Loading