{"record":{"id":"9f90c2e3c4203477","repo":"slimtoolkit/slim","slug":"unknown-instruction","errorCode":null,"errorMessage":"unknown instruction","messagePattern":"unknown instruction","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/docker/dockerfile/ast/parser.go","lineNumber":25,"sourceCode":"\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n\n\t\"github.com/pkg/errors\"\n\t\"github.com/slimtoolkit/slim/pkg/docker/instruction\"\n)\n\nconst (\n\tUnknownInstMsg = \"unknown instruction\"\n)\n\nvar (\n\tErrDockerfileUnknownInst = errors.New(UnknownInstMsg)\n)\n\ntype ParseError struct {\n\tContext string\n\tData    string\n\tMessage string\n}\n\nfunc (e ParseError) Error() string {\n\treturn e.Message\n}\n\nfunc pe(context, data, message string) ParseError {\n\treturn ParseError{\n\t\tContext: context,\n\t\tData:    data,\n\t\tMessage: message,\n\t}","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/docker/dockerfile/ast/parser.go#L7-L43","documentation":"ErrDockerfileUnknownInst is the sentinel error for unrecognized Dockerfile instructions; its message is the constant UnknownInstMsg ('unknown instruction'). The AST parser's dispatch table maps known instruction keywords to line parsers, and any keyword not in the table produces this error (often wrapped in a ParseError with the offending line).","triggerScenarios":"Parsing a Dockerfile containing a misspelled or unsupported instruction (e.g., RUNN, INSTAL); using an instruction from a newer/other builder (BuildKit-only syntax like heredoc headers) with this parser; custom instructions the slim linter doesn't know.","commonSituations":"Typos in Dockerfile keywords; copy-pasting syntax from other tools (CI yaml, shell scripts pasted into the Dockerfile); parser not updated for new Docker instructions.","solutions":["Fix the instruction spelling to a valid Dockerfile keyword (RUN, COPY, ENV, etc.)","Remove or comment out the unsupported line","Upgrade the parser/tooling if the instruction is valid in newer Docker/BuildKit versions","Check for lines accidentally pasted that are not Dockerfile instructions"],"exampleFix":"# before\nRUNN apt-get update\n# after\nRUN apt-get update","handlingStrategy":"type-guard","validationCode":"// Go: validate instruction keywords against the known set before parsing\nvar known = map[string]bool{\"RUN\": true, \"CMD\": true, \"COPY\": true, \"FROM\": true /* ... */}\nif !known[strings.ToUpper(keyword)] {\n    return fmt.Errorf(\"unsupported instruction: %s\", keyword)\n}","typeGuard":"func IsUnknownInstruction(err error) bool {\n    return errors.Is(err, ast.ErrDockerfileUnknownInst) ||\n        strings.Contains(err.Error(), ast.UnknownInstMsg)\n}","tryCatchPattern":"res, err := ast.Parse(dockerfile)\nif err != nil {\n    if errors.Is(err, ast.ErrDockerfileUnknownInst) {\n        // report the offending line/context from ParseError\n    }\n    return err\n}","preventionTips":["Spell-check Dockerfile instructions; run hadolint or the built-in linter in CI","Watch for non-Dockerfile lines accidentally pasted into the file","Keep the slim parser updated for new Docker/BuildKit instructions"],"tags":["dockerfile","parsing","typo","go"],"backgroundTag":"unknown-dockerfile-instruction","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}