{"record":{"id":"f78ad0b18d331248","repo":"bagisto/bagisto","slug":"not-found-f78ad0","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":"NotFoundHttpException","httpStatus":404,"severity":"warning","filePath":"packages/Webkul/Admin/src/Http/Controllers/Reporting/Controller.php","lineNumber":88,"sourceCode":"    /**\n     * Validate if the requested type is valid.\n     *\n     * @return void\n     */\n    protected function validateRequestedType()\n    {\n        return ! array_key_exists(request()->query('type'), $this->typeFunctions);\n    }\n\n    /**\n     * Resolve the requested type into a valid function name.\n     *\n     * @return string\n     */\n    protected function resolveTypeFunction()\n    {\n        if ($this->validateRequestedType()) {\n            abort(404);\n        }\n\n        return $this->typeFunctions[request()->query('type')];\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":94,"githubUrl":"https://github.com/bagisto/bagisto/blob/326bc45f17cd66d2835a934d21c264d3ee12d935/packages/Webkul/Admin/src/Http/Controllers/Reporting/Controller.php#L70-L94","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","For a custom report type, extend the child controller's $typeFunctions with 'my-type' => 'myHelperMethod' and implement that method on the Reporting helper.","Ensure the JS/widget building reporting URLs always appends type — a request without it aborts 404."],"exampleFix":"// before — slug not in the map → abort(404)\nGET .../stats?type=totals\n\n// after — add the slug to $typeFunctions in the reporting controller\nprotected $typeFunctions = [\n    'totals' => 'getTotalSalesStats', // now ?type=totals resolves\n    // ...\n];","handlingStrategy":"validation","validationCode":"$validTypes = array_keys($reportingController->typeFunctions ?? [\n    'total-sales', 'average-sales', 'total-orders', 'purchase-funnel',\n    'abandoned-carts', 'refunds', 'tax-collected', 'shipping-collected',\n    'top-payment-methods', 'sales-by-coupon',\n]);\n\n$type = request()->query('type');\n\nif (! in_array($type, $validTypes, true)) {\n    abort(400, \"Unknown reporting type: {$type}\");\n}","typeGuard":"function isValidReportingType(?string $type, array $typeFunctions): bool\n{\n    return $type !== null && array_key_exists($type, $typeFunctions);\n}","tryCatchPattern":null,"preventionTips":["Treat the ?type= slug as API contract — when renaming a $typeFunctions key, grep JS/blade assets for the old slug.","Prefer a 400 with a message in your own wrappers so a bad type is distinguishable from a wrong URL.","Centralize valid slugs per entity in one constant shared between server and front-end."],"tags":["bagisto","laravel","reporting","query-params","http-404","admin-panel"],"backgroundTag":"invalid-query-parameter","analyzedSha":"326bc45f17cd66d2835a934d21c264d3ee12d935","analyzedAt":"2026-08-17T00:51:54.202Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}