-
Notifications
You must be signed in to change notification settings - Fork 238
fix(process-pdf-job): discard on RuntimeError and guard failed status #2453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| class ProcessPdfJob < ApplicationJob | ||
| queue_as :medium_priority | ||
|
|
||
| discard_on(RuntimeError) do |job, err| | ||
| Rails.logger.error("[ProcessPdfJob] Discarded permanently (job_id=#{job.job_id}): #{err.message}") | ||
| end | ||
|
|
||
| def perform(pdf_import) | ||
| return unless pdf_import.is_a?(PdfImport) | ||
| return reset_processing_claim(pdf_import) unless pdf_import.pdf_uploaded? | ||
| return if pdf_import.status == "complete" | ||
| return if pdf_import.status.in?(%w[complete failed]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a non- Useful? React with 👍 / 👎. |
||
| return reset_processing_claim(pdf_import) if pdf_import.ai_processed? && (!pdf_import.statement_with_transactions? || pdf_import.rows_count > 0) | ||
|
|
||
| pdf_import.update!(status: :importing) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This treats every bare
raise "..."as non-retryable, butPdfImport#process_with_aiand#extract_transactionsturn any unsuccessful provider response into exactly that by raising the response message. Since the providers also wrap API/Faraday failures into unsuccessful responses, a transient LLM outage or rate limit is now discarded after one attempt and left failed; use a narrower permanent-error class for bad PDFs/passwords.Useful? React with 👍 / 👎.