{"record":{"id":"765953be5a1cac85","repo":"slimtoolkit/slim","slug":"got-an-invalid-escape-sequence-s","errorCode":null,"errorMessage":"got an invalid escape sequence: %s","messagePattern":"got an invalid escape sequence: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/docker/dockerfile/reverse/reverse.go","lineNumber":849,"sourceCode":"\t\t\t// retries are a unicode string\n\t\t\tretries, err = strconv.ParseInt(strings.TrimPrefix(paramParts[3], `\\U`), 16, 64)\n\t\t} else if strings.Index(paramParts[3], `\\`) == 0 {\n\t\t\t// retries is printed as a C-escape\n\t\t\tif len(paramParts[3]) != 2 {\n\t\t\t\terr = fmt.Errorf(\"expected retries (%s) to be an escape sequence\", paramParts[3])\n\t\t\t} else {\n\t\t\t\tescapeCodes := map[byte]int64{\n\t\t\t\t\tbyte('a'): 7,\n\t\t\t\t\tbyte('b'): 8,\n\t\t\t\t\tbyte('t'): 9,\n\t\t\t\t\tbyte('n'): 10,\n\t\t\t\t\tbyte('v'): 11,\n\t\t\t\t\tbyte('f'): 12,\n\t\t\t\t\tbyte('r'): 13,\n\t\t\t\t}\n\t\t\t\tvar ok bool\n\t\t\t\tif retries, ok = escapeCodes[(paramParts[3])[1]]; !ok {\n\t\t\t\t\terr = fmt.Errorf(\"got an invalid escape sequence: %s\", paramParts[3])\n\t\t\t\t}\n\t\t\t}\n\t\t} else if len(paramParts[3]) > 0 {\n\t\t\tretries = int64((paramParts[3])[0])\n\t\t}\n\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"[%s] config.Retries err = %v\", paramParts[3], err)\n\t\t} else {\n\t\t\tconfig.Retries = int(retries)\n\t\t}\n\n\t\tvar testType string\n\t\tif len(config.Test) > 0 {\n\t\t\ttestType = config.Test[0]\n\t\t}\n\n\t\tswitch testType {","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/docker/dockerfile/reverse/reverse.go#L831-L867","documentation":"While decoding the HEALTHCHECK retries value as a C-escape, the second character is looked up in a table of known escapes (\\a \\b \\t \\n \\v \\f \\r). If the byte after the backslash is not one of these, the parser cannot map it to a numeric retries value and records this error on the returned err.","triggerScenarios":"A HEALTHCHECK 4th parameter of exactly 2 characters starting with a backslash whose second character is not a recognized escape letter, e.g. \\\\q, \\\\1, \\\\s, when calling the reverse Dockerfile builder (FailOn/Error/Run/NewBasicImageBuilder).","commonSituations":"History metadata containing octal/hex escapes (\\\\033, \\\\x07) that the parser does not support; typos in hand-written HEALTHCHECK strings; tooling that URL- or shell-escaped the retries value.","solutions":["Replace the retries parameter with a supported escape (\\a, \\b, \\t, \\n, \\v, \\f, \\r), a \\Uxxxx unicode escape, or a plain numeric string.","Remove the HEALTHCHECK metadata if the original escape is required and cannot be represented.","Patch the ingestion to accept the escape by normalizing the history value before invoking the reverse builder."],"exampleFix":"// before (unsupported escape)\nHEALTHCHECK --retries=\\\\q [\"CMD\", \"curl\", \"-f\", \"http://localhost/\"]\n// after (supported escape)\nHEALTHCHECK --retries=\\\\n [\"CMD\", \"curl\", \"-f\", \"http://localhost/\"]","handlingStrategy":"validation","validationCode":"var validEscapes = map[byte]bool{'a':true,'b':true,'t':true,'n':true,'v':true,'f':true,'r':true}\nfunc validEscape(p string) bool {\n\treturn !strings.HasPrefix(p, \"\\\\\") || strings.HasPrefix(p, \"\\\\U\") || (len(p) == 2 && validEscapes[p[1]])\n}","typeGuard":null,"tryCatchPattern":"if err := buildErr; err != nil && strings.Contains(err.Error(), \"invalid escape sequence\") {\n\t// normalize retries to numeric form and retry the build\n}","preventionTips":["Use only supported C-escapes (\\a \\b \\t \\n \\v \\f \\r) or numeric retries","Convert octal/hex escapes to plain numbers before ingestion","Test HEALTHCHECK parsing against images from all build toolchains you support"],"tags":["dockerfile","healthcheck","escape-sequence","docker"],"backgroundTag":"invalid-escape-sequence","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}