def mark_product_failed()

in tooling/enrichment/firestore_client.py [0:0]


    def mark_product_failed(self, product_id, error_message):
        """Mark a product as failed with error details."""
        doc_ref = self.collection.document(str(product_id))
        doc = doc_ref.get()
        
        update_data = {
            'status': 'failed',
            'error_message': error_message,
            'failed_at': firestore.SERVER_TIMESTAMP,
            'updated_at': firestore.SERVER_TIMESTAMP
        }
        
        if doc.exists:
            retry_count = doc.to_dict().get('retry_count', 0)
            update_data['retry_count'] = retry_count
            
            # If we've tried 3 times, mark as permanently failed
            if retry_count >= 3:
                update_data['status'] = 'permanently_failed'
        
        doc_ref.update(update_data)