{"record":{"id":"76b9c52f5d644c65","repo":"twigphp/Twig","slug":"unknown-attribute-type-s-the-only-supported-types-are-sst","errorCode":null,"errorMessage":"Unknown attribute type \"%s\" The only supported types are \"sst\", \"cst\" and \"style\".","messagePattern":"Unknown attribute type \"(.+?)\" The only supported types are \"sst\", \"cst\" and \"style\"\\.","errorType":"exception","errorClass":"Twig\\Error\\RuntimeError","httpStatus":null,"severity":"error","filePath":"extra/html-extra/HtmlExtension.php","lineNumber":145,"sourceCode":"     * @param array<string, array<string, string|array<string>>> $variants\n     * @param array<array<string, string|array<string>>>         $compoundVariants\n     * @param array<string, string>                              $defaultVariant\n     *\n     * @internal\n     */\n    public static function htmlCva(array|string $base = [], array $variants = [], array $compoundVariants = [], array $defaultVariant = []): Cva\n    {\n        return new Cva($base, $variants, $compoundVariants, $defaultVariant);\n    }\n\n    /** @internal */\n    public static function htmlAttrType(mixed $value, string $type = 'sst'): AttributeValueInterface\n    {\n        return match ($type) {\n            'sst' => new SeparatedTokenList($value, ' '),\n            'cst' => new SeparatedTokenList($value, ', '),\n            'style' => new InlineStyle($value),\n            default => throw new RuntimeError(\\sprintf('Unknown attribute type \"%s\" The only supported types are \"sst\", \"cst\" and \"style\".', $type)),\n        };\n    }\n\n    /** @internal */\n    public static function htmlAttrMerge(iterable|string|false|null ...$arrays): array\n    {\n        $result = [];\n\n        foreach ($arrays as $array) {\n            if (!$array) {\n                continue;\n            }\n\n            if (\\is_string($array)) {\n                throw new RuntimeError('Only empty strings may be passed as string arguments to html_attr_merge. This is to support the implicit else clause for ternary operators.');\n            }\n\n            foreach ($array as $key => $value) {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/html-extra/HtmlExtension.php#L127-L163","documentation":"The html_attr() helper supports special attribute-value types via the htmlAttrType() converter: 'sst' (space-separated token list), 'cst' (comma-separated token list) and 'style' (inline CSS). Any other type string hits the match() default arm and throws this RuntimeError.","triggerScenarios":"Calling HtmlExtension::htmlAttrType($value, $type) with $type not in ['sst','cst','style'], e.g. htmlAttrType($value, 'class') or a typo like 'styles'.","commonSituations":"Typo in the type string in a Twig template; copying an option name from another helper; passing user-controlled type config that was never validated.","solutions":["Use only 'sst', 'cst' or 'style' as the type argument.","Fix typos ('styles' -> 'style', 'csv' -> 'cst').","Validate/config-whitelist the type value before passing it through.","If you need a new type, extend with your own AttributeValueInterface implementation instead of a new string."],"exampleFix":"// before\nhtmlAttrType($value, 'csv')\n// after\nhtmlAttrType($value, 'cst')","handlingStrategy":"validation","validationCode":"if (!in_array($type, ['sst','cst','style'], true)) { throw new \\InvalidArgumentException(\"Unsupported attr type $type\"); }","typeGuard":"function isSupportedAttrType(string $t): bool { return in_array($t, ['sst','cst','style'], true); }","tryCatchPattern":"try { $v = HtmlExtension::htmlAttrType($value, $type); } catch (Twig\\Error\\RuntimeError $e) { $v = new SeparatedTokenList($value, ' '); }","preventionTips":["Keep the three allowed type strings in a shared constant","Whitelist user/config-supplied type values","grep templates for htmlAttrType usages when refactoring"],"tags":["twig","enum","html-attr"],"backgroundTag":"invalid-enum-value","analyzedSha":"a414c3a491defb5a60f2fc88ef79ff37c90010cd","analyzedAt":"2026-09-13T15:10:46.849Z","contentChangedAt":"2026-09-13T15:10:46.849Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}