octobercms/october · error · Error

options.extension must be set for cssimports click handler

Error message

options.extension must be set for cssimports click handler

What it means

Configuration guard in the cssimports intellisense click handler: the handler was constructed without the extension reference it needs to resolve CMS asset links, so provideLinks cannot build link targets. The options object passed at construction is missing extension.

Solutions

  1. Pass options.extension (the editor extension instance) when creating the cssimports click handler
  2. Check handler instantiation in the intellisense setup code
  3. Add a constructor assertion/default for missing options
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/cms/assets/js/cms.editor.intellisense.clickhandler.cssimports.js:74 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/52576e3bb60e06ce. Report an issue: GitHub.

Appendix: source

Thrown at modules/cms/assets/js/cms.editor.intellisense.clickhandler.cssimports.js:74

            const templatePos = findMatch.matches[0].indexOf(templateName);
            const startColumn = findMatch.range.startColumn + templatePos;

            links.push({
                type: 'cms-asset',
                templateName: fullTemplateName,
                range: {
                    endColumn: startColumn + templateName.length,
                    endLineNumber: findMatch.range.endLineNumber,
                    startColumn: startColumn,
                    startLineNumber: findMatch.range.startLineNumber
                }
            });
        });
    }

    provideLinks(model, token) {
        if (typeof this.options.extension !== 'string') {
            throw new Error('options.extension must be set for cssimports click handler');
        }

        if (!this.intellisense.modelHasTag(model, 'cms-asset-contents')) {
            return;
        }

        const basePath = 'assets/' + this.intellisense.getModelCustomAttribute(model, 'filePath');
        const result = {
            links: []
        };

        this.makeLinks(model, /@import\s+("|')([a-zA-Z0-9\-\/_\.]+)\1/gm, result.links, basePath, {
            allowedExtensions: [this.options.extension, null]
        });

        return result;
    }
}

View on GitHub (pinned to b608633a7e)