{"record":{"id":"6b6c653a34edd69d","repo":"slimtoolkit/slim","slug":"bad-instruction-prefix","errorCode":null,"errorMessage":"bad instruction prefix","messagePattern":"bad instruction prefix","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/docker/dockerfile/reverse/reverse.go","lineNumber":21,"sourceCode":"import (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/dustin/go-humanize\"\n\tdocker \"github.com/fsouza/go-dockerclient\"\n\t\"github.com/google/shlex\"\n\tlog \"github.com/sirupsen/logrus\"\n)\n\nvar (\n\tErrBadInstPrefix = errors.New(\"bad instruction prefix\")\n)\n\n// Dockerfile represents the reverse engineered Dockerfile info\ntype Dockerfile struct {\n\tLines                    []string             `json:\"lines,omitempty\"`\n\tMaintainers              []string             `json:\"maintainers,omitempty\"`\n\tAllUsers                 []string             `json:\"all_users,omitempty\"`\n\tExeUser                  string               `json:\"exe_user,omitempty\"`\n\tExposedPorts             []string             `json:\"exposed_ports,omitempty\"`\n\tImageStack               []*ImageInfo         `json:\"image_stack\"`\n\tAllInstructions          []*InstructionInfo   `json:\"all_instructions\"`\n\tInstructionGroups        [][]*InstructionInfo `json:\"instruction_groups\"`\n\tInstructionGroupsReverse [][]*InstructionInfo `json:\"instruction_groups_reverse\"`\n\tHasOnbuild               bool                 `json:\"has_onbuild\"`\n}\n\ntype ImageInfo struct {\n\tIsTopImage   bool               `json:\"is_top_image\"`","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/docker/dockerfile/reverse/reverse.go#L3-L39","documentation":"ErrBadInstPrefix is returned by the dockerfile reverse-engineering package when a parsed instruction line does not start with a recognized Dockerfile instruction prefix. The reverse parser maps image history/lines back to Dockerfile instructions and cannot classify a line whose prefix it does not know. It signals unexpected or malformed line content rather than caller misuse.","triggerScenarios":"Reverse-engineering a Dockerfile from image history where a history line's first token is not a known instruction keyword (FROM, RUN, MAINTAINER, etc.).","commonSituations":"Images built by non-standard builders or with unusual metadata comments in history; older/newer Docker instruction keywords not covered by the reverse parser's prefix table.","solutions":["Inspect the source image's history (docker history --no-trunc) for lines with unexpected first tokens.","Update slimtoolkit to a version whose reverse parser recognizes the instruction prefix in question.","Skip or sanitize unrecognized history lines before passing them to the reverse package.","If the line is a builder comment or metadata artifact, strip it prior to reverse engineering."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"firstToken := strings.Fields(line)[0]\nknown := map[string]bool{\"FROM\":true,\"RUN\":true,\"CMD\":true,\"LABEL\":true,\"MAINTAINER\":true,\"EXPOSE\":true,\"ENV\":true,\"ADD\":true,\"COPY\":true,\"ENTRYPOINT\":true,\"VOLUME\":true,\"USER\":true,\"WORKDIR\":true,\"ARG\":true,\"ONBUILD\":true,\"STOPSIGNAL\":true,\"HEALTHCHECK\":true,\"SHELL\":true}\nif !known[strings.ToUpper(firstToken)] { /* skip or log line */ }","typeGuard":null,"tryCatchPattern":"df, err := reverse.FromImage(...)\nif errors.Is(err, reverse.ErrBadInstPrefix) {\n    log.Warnf(\"skipping unrecognized instruction line: %v\", err)\n    // proceed with partial result or sanitize input and retry\n}","preventionTips":["Pre-trim history lines and skip comment/metadata lines.","Keep the library updated to cover newer Docker instruction keywords.","Audit image history with 'docker history --no-trunc' before reverse engineering.","Log the offending line so the prefix table can be extended."],"tags":["dockerfile","reverse-engineering","instruction"],"backgroundTag":"unrecognized-instruction","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}