{"record":{"id":"49932fbcb36a8ecb","repo":"flarum/framework","slug":"source-type-s-is-not-allowed-for-this-collector-allowed","errorCode":null,"errorMessage":"Source type %s is not allowed for this collector. Allowed types are: %s","messagePattern":"Source type (.+?) is not allowed for this collector\\. Allowed types are: (.+?)","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"framework/core/src/Frontend/Compiler/Source/SourceCollector.php","lineNumber":84,"sourceCode":"    {\n        return $this->sources;\n    }\n\n    protected function validateSourceType(SourceInterface $source): SourceInterface\n    {\n        // allowedSourceTypes is an array of class names (or interface names)\n        // so we need to check if the $source is an instance of one of those classes/interfaces (could be a parent class as well)\n        $isInstanceOfOneOfTheAllowedSourceTypes = false;\n\n        foreach ($this->allowedSourceTypes as $allowedSourceType) {\n            if ($source instanceof $allowedSourceType) {\n                $isInstanceOfOneOfTheAllowedSourceTypes = true;\n                break;\n            }\n        }\n\n        if (! empty($this->allowedSourceTypes) && ! $isInstanceOfOneOfTheAllowedSourceTypes) {\n            throw new \\InvalidArgumentException(sprintf(\n                'Source type %s is not allowed for this collector. Allowed types are: %s',\n                $source::class,\n                implode(', ', $this->allowedSourceTypes)\n            ));\n        }\n\n        return $source;\n    }\n}\n","sourceCodeStart":66,"sourceCodeEnd":94,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Frontend/Compiler/Source/SourceCollector.php#L66-L94","documentation":"Guard in SourceCollector::validateSourceType, run for every file/string/directory added to a frontend asset collector: if the collector was constructed with a restricted allowedSourceTypes list and the submitted SourceInterface implementation is not an instance of any allowed class/interface, the source cannot be compiled by this collector and an InvalidArgumentException is thrown naming the offending class and the allowed types.","triggerScenarios":"Thrown at framework/core/src/Frontend/Compiler/Source/SourceCollector.php:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the collector type intended for that source (e.g. Js vs Css collectors)","Make the custom source implement/extend one of the collector's allowed source types","Adjust the collector's allowedSourceTypes if you own the extension point","Register the source with the correct Extend\\Frontend extender"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}