{"record":{"id":"83a71198c5b9bc9d","repo":"junegunn/fzf","slug":"template-should-include-at-least-1-placeholder","errorCode":null,"errorMessage":"template should include at least 1 placeholder: ${str}","messagePattern":"template should include at least 1 placeholder: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/options.go","lineNumber":875,"sourceCode":"func nthTransformer(str string) (func(Delimiter) func([]Token, int32) string, error) {\n\t// ^[0-9,-.]+$\"\n\tif match, _ := regexp.MatchString(\"^[0-9,-.]+$\", str); match {\n\t\tnth, err := splitNth(str)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn func(Delimiter) func([]Token, int32) string {\n\t\t\treturn func(tokens []Token, index int32) string {\n\t\t\t\treturn JoinTokens(Transform(tokens, nth))\n\t\t\t}\n\t\t}, nil\n\t}\n\n\t// {...} {...} ...\n\tplaceholder := regexp.MustCompile(\"{[0-9,-.]+}|{n}\")\n\tindexes := placeholder.FindAllStringIndex(str, -1)\n\tif indexes == nil {\n\t\treturn nil, errors.New(\"template should include at least 1 placeholder: \" + str)\n\t}\n\n\ttype NthParts struct {\n\t\tstr   string\n\t\tindex bool\n\t\tnth   []Range\n\t}\n\n\tparts := make([]NthParts, 0, len(indexes))\n\tidx := 0\n\tfor _, index := range indexes {\n\t\tif idx < index[0] {\n\t\t\tparts = append(parts, NthParts{str: str[idx:index[0]]})\n\t\t}\n\t\texpr := str[index[0]+1 : index[1]-1]\n\t\tif expr == \"n\" {\n\t\t\tparts = append(parts, NthParts{index: true})\n\t\t} else if nth, err := splitNth(expr); err == nil {","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/options.go#L857-L893","documentation":"nthTransformer accepts either a plain range list or a template containing placeholders like {1}, {2..5}, {n}, or {..3}. If the --nth argument is neither (contains no {…} placeholder at all), this error demands at least one placeholder. It fires after the plain-range branch was already ruled out.","triggerScenarios":"Passing --nth '{ }' (space inside braces, so regex {[0-9,-.]+}|{n} misses it), --nth '{}', --nth 'field{n}' is OK but --nth 'field' (forgot the placeholder) fails, --nth '{1-2}' with a single hyphen (regex only matches '..' ranges inside braces) also fails the placeholder match.","commonSituations":"Users writing {1-3} instead of {1..3} in template mode; forgetting the {n} placeholder in joiner templates; using single-hyphen ranges in both --nth forms out of habit from other tools.","solutions":["Inside {} placeholders use '..' ranges, not '-': --nth {1..3},7","Ensure at least one placeholder exists: append {n} if you want all fields","Use the comma-separated plain form without braces when templates are not needed"],"exampleFix":"# before\nfzf --nth '{1-3},7'\n# after\nfzf --nth '{1..3},7'","handlingStrategy":"validation","validationCode":"NTH='{1..3},7'\ngrep -Eq '\\{([0-9,-]+\\.\\.[0-9,-]*|[0-9,-]+|n)\\}' <<< \"$NTH\" || { echo 'nth template lacks a {..} placeholder' >&2; exit 1; }\nfzf --nth \"$NTH\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In template mode every placeholder needs '..' for ranges: {1..3} not {1-3}","Always include at least one placeholder ({n} covers 'all fields')","Prefer the plain comma form unless you need literal text around fields"],"tags":["fzf","options-parsing","nth","template","go"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}