© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
ChickenDev

Importer RowImportFailedException

I've created an importer that is supposed to bail if it encounters references to data that doesn't exist in my database.

However, when I run a test using a CSV with 1 valid row and 1 invalid row, the exception is thrown but the importer then ends up in an infinite loop and I get multiple copies of the valid row imported until I kill the queue.

Here's my
resolveRecord
resolveRecord
function that is intended to throw the exception:

public function resolveRecord(): ?InvoiceItem
    {
        $invoiceNumber = $this->data['invoice_number'];
        $invoice = Invoice::query()
            ->where('invoice_number', $invoiceNumber)
            ->first();

        $productSku = $this->data['product_sku'];
        $product = Product::query()
            ->where('sku', $productSku)
            ->first();

        if ($invoice == NULL || $product == NULL) {
            throw new RowImportFailedException("Product with SKU [{$this->data['product_sku']}] and/or Invoice with Name [{$this->data['invoice_number']}] not found.");
        }

        $newInvoiceItem = new InvoiceItem();
        $newInvoiceItem->invoice_id = $invoice->id;
        $newInvoiceItem->product_id = $product->id;

        return $newInvoiceItem;
    }
public function resolveRecord(): ?InvoiceItem
    {
        $invoiceNumber = $this->data['invoice_number'];
        $invoice = Invoice::query()
            ->where('invoice_number', $invoiceNumber)
            ->first();

        $productSku = $this->data['product_sku'];
        $product = Product::query()
            ->where('sku', $productSku)
            ->first();

        if ($invoice == NULL || $product == NULL) {
            throw new RowImportFailedException("Product with SKU [{$this->data['product_sku']}] and/or Invoice with Name [{$this->data['invoice_number']}] not found.");
        }

        $newInvoiceItem = new InvoiceItem();
        $newInvoiceItem->invoice_id = $invoice->id;
        $newInvoiceItem->product_id = $product->id;

        return $newInvoiceItem;
    }


The exception gets logged in my laravel.log file, but I do not see any results in the UI for the import.
Solution
Turns out it was a simple solution.
I hadn't included the RowImportFailedException type in the file and so the exception being thrown was actually a class not found exception. I didn't notice that!
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Weird Importer
FilamentFFilament / ❓┊help
6mo ago
Importer issue
FilamentFFilament / ❓┊help
6mo ago
product importer
FilamentFFilament / ❓┊help
12mo ago
CSV Importer
FilamentFFilament / ❓┊help
2y ago