{"record":{"id":"9c5f246056cadb74","repo":"gohugoio/hugo","slug":"s-invalid-state-invalid-param-type-t-for-short-9c5f24","errorCode":null,"errorMessage":"%s: invalid state: invalid param type %T for shortcode %q, expected a slice","messagePattern":"(.+?): invalid state: invalid param type %T for shortcode %q, expected a slice","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/shortcode.go","lineNumber":704,"sourceCode":"\t\t\t\t} else {\n\t\t\t\t\tif params, ok := sc.params.(map[string]any); ok {\n\t\t\t\t\t\tparams[currItem.ValStr(source)] = pt.Next().ValTyped(source)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn sc, fmt.Errorf(\"%s: invalid state: invalid param type %T for shortcode %q, expected a map\", errorPrefix, params, sc.name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// positional params\n\t\t\t\tif sc.params == nil {\n\t\t\t\t\tvar params []any\n\t\t\t\t\tparams = append(params, currItem.ValTyped(source))\n\t\t\t\t\tsc.params = params\n\t\t\t\t} else {\n\t\t\t\t\tif params, ok := sc.params.([]any); ok {\n\t\t\t\t\t\tparams = append(params, currItem.ValTyped(source))\n\t\t\t\t\t\tsc.params = params\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn sc, fmt.Errorf(\"%s: invalid state: invalid param type %T for shortcode %q, expected a slice\", errorPrefix, params, sc.name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase currItem.IsDone():\n\t\t\tif !currItem.IsError() {\n\t\t\t\tif !closed && sc.needsInner() {\n\t\t\t\t\treturn sc, fmt.Errorf(\"%s: shortcode %q must be closed or self-closed\", errorPrefix, sc.name)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// handled by caller\n\t\t\tpt.Backup()\n\t\t\tbreak Loop\n\n\t\t}\n\t}\n\treturn sc, nil\n}\n","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/shortcode.go#L686-L722","documentation":"Mirror of the named-param case: while collecting positional (space-separated) parameters, the parser found the shortcode's params field already held a non-slice value (typically a map[string]any from earlier named key=value args). The current token is positional but the existing state is a map, so appending to a slice fails. As with the sibling error, this signals mixed named/positional parameter styles within a single shortcode invocation.","triggerScenarios":"A shortcode call that starts with named arguments then adds positional ones, e.g. {{< mysc key=\"x\" positionalval >}}. After sc.params is set to map[string]any, a later positional token hits the branch at shortcode.go:700-704 and fails.","commonSituations":"Editing an existing named-parameter shortcode invocation and appending a bare positional value; inconsistent partial template includes passing mixed args; content migrated between shortcodes with different param conventions.","solutions":["Pick one parameter style for the invocation and apply it to all arguments.","Inspect the shortcode template to see whether it calls .Get(int) (positional) or .Get(key) (named) and align the call.","Use the error prefix location to jump to the exact content file and fix the mixed invocation."],"exampleFix":"// before\n{{< mysc key=\"x\" positionalval >}}\n\n// after (all named)\n{{< mysc key=\"x\" second=\"positionalval\" >}}","handlingStrategy":"validation","validationCode":"func validateShortcodeParams(tokens []scToken) error {\n    seenNamed, seenPositional := false, false\n    for _, t := range tokens {\n        if t.isNamedParam()  { seenNamed = true }\n        if t.isPositional()  { seenPositional = true }\n        if seenNamed && seenPositional {\n            return fmt.Errorf(\"shortcode %q mixes named and positional params\", tokens[0].name)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never interleave key=value and bare values in one shortcode call.","Document each shortcode's param convention at the top of its template.","Add a content lint step that flags '=' alongside bare params."],"tags":["shortcode","template","parsing","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}