diff --git a/application_handler.py b/application_handler.py index 0ed2f76..efd0818 100644 --- a/application_handler.py +++ b/application_handler.py @@ -108,7 +108,22 @@ class ApplicationHandler: message += f"\nReason: {html.escape(fail_msg)}" else: # Should not happen if logic is correct, but fallback + # Save as failed so /retryfailed can retry later message += "\n\n\u2139\ufe0f No application attempted (internal logic error)" + failed_result = { + "listing_id": listing["id"], + "company": company, + "link": link, + "timestamp": listing.get("timestamp", ""), + "success": False, + "message": "Internal logic error: listing not in application_results", + "address": listing.get("address", ""), + "rooms": listing.get("rooms", ""), + "price": listing.get("price", ""), + "retries": 0 + } + self.save_application(failed_result) + logger.warning(f"[INTERNAL ERROR] Saved as failed: {listing['id']} - {listing.get('address', '')}") else: # Autopilot was off or not attempted at all message += "\n\n\u2139\ufe0f No application attempted (autopilot off)"