bagisto/bagisto · warning · NotFoundHttpException

Not Found

Error message

Not Found

What it means

Base controller for Bagisto's admin Reporting section. Every reporting endpoint (stats, viewStats, export) resolves the ?type= query parameter into a Reporting helper method via the child controller's $typeFunctions map. validateRequestedType() returns true when request()->query('type') is not a key of that map, and resolveTypeFunction() then aborts(404) before any helper call — 'Not Found' is Laravel's default message for a bare abort(404).

Source

Thrown at packages/Webkul/Admin/src/Http/Controllers/Reporting/Controller.php:88

    /**
     * Validate if the requested type is valid.
     *
     * @return void
     */
    protected function validateRequestedType()
    {
        return ! array_key_exists(request()->query('type'), $this->typeFunctions);
    }

    /**
     * Resolve the requested type into a valid function name.
     *
     * @return string
     */
    protected function resolveTypeFunction()
    {
        if ($this->validateRequestedType()) {
            abort(404);
        }

        return $this->typeFunctions[request()->query('type')];
    }
}

View on GitHub (pinned to 326bc45f17)

Solutions

  1. Send a ?type= that is a key of the target controller's $typeFunctions (open Reporting/CustomerController.php, ProductController.php or SaleController.php for the exact slugs).
  2. For a custom report type, extend the child controller's $typeFunctions with 'my-type' => 'myHelperMethod' and implement that method on the Reporting helper.
  3. Ensure the JS/widget building reporting URLs always appends type — a request without it aborts 404.

Example fix

// before — slug not in the map → abort(404)
GET .../stats?type=totals

// after — add the slug to $typeFunctions in the reporting controller
protected $typeFunctions = [
    'totals' => 'getTotalSalesStats', // now ?type=totals resolves
    // ...
];
Defensive patterns

Strategy: validation

Validate before calling

$validTypes = array_keys($reportingController->typeFunctions ?? [
    'total-sales', 'average-sales', 'total-orders', 'purchase-funnel',
    'abandoned-carts', 'refunds', 'tax-collected', 'shipping-collected',
    'top-payment-methods', 'sales-by-coupon',
]);

$type = request()->query('type');

if (! in_array($type, $validTypes, true)) {
    abort(400, "Unknown reporting type: {$type}");
}

Type guard

function isValidReportingType(?string $type, array $typeFunctions): bool
{
    return $type !== null && array_key_exists($type, $typeFunctions);
}

Prevention

When it happens

Trigger: Calling reporting stats/view-stats/export endpoints with a ?type= that is not a key of the entity's $typeFunctions, or omitting ?type= entirely (null is never a key). Examples: ?type=total-sales on the customer report (valid keys: total-customers, customers-with-most-sales, customers-with-most-orders, customers-with-most-reviews, top-customer-groups), or a renamed slug after customization.

Common situations: Custom dashboards or scheduled export scripts copying a type value from a different reporting section; extending $typeFunctions but still requesting the old slug; typos and dash/underscore confusion in the query string.

Related errors


AI-assisted analysis of bagisto/bagisto@326bc45f17 (2026-08-17). Data as JSON: /api/errors/f78ad0b18d331248. Report an issue: GitHub.