slimtoolkit/slim · error
malformed HEALTHCHECK parameters: %q
Error message
malformed HEALTHCHECK parameters: %q
What it means
Thrown by the Dockerfile reverse-engineering parser when reconstructing a HEALTHCHECK instruction: the instruction body could not be split into the 4 required parameters (start-interval/check timing fields of the healthcheck flags). The parser splits the remainder of the HEALTHCHECK line on spaces with SplitN(..., 4) and requires all 4 parts; anything fewer means the parameters are structurally malformed, so the builder aborts with the offending data quoted.
Source
Thrown at pkg/docker/dockerfile/reverse/reverse.go:804
}
// Cleans HEALTHCHECK part and splits the first part further
parts := strings.SplitN(instParts[0], " ", 2)
// joins the first part of the string
instPart1 := strings.Join(parts[1:], " ")
// removes quotes from the first part of the string
instPart1 = strings.ReplaceAll(instPart1, "\"", "")
// cleans it to assign it to the pointer config.Test
config.Test = strings.Split(instPart1, " ")
// removes the } from the second part of the string
instPart2 := strings.Replace(instParts[1], "}", "", -1)
// removes extra spaces from string
instPart2 = strings.TrimSpace(instPart2)
paramParts := strings.SplitN(instPart2, " ", 4)
if len(paramParts) < 4 {
return strTest, &config, fmt.Errorf("malformed HEALTHCHECK parameters: %q", data)
}
for i, param := range paramParts {
paramParts[i] = strings.Trim(param, "\"'")
}
var err error
config.Interval, err = time.ParseDuration(paramParts[0])
if err != nil {
log.Errorf("[%s] config.Interval err = %v", paramParts[0], err)
}
config.Timeout, err = time.ParseDuration(paramParts[1])
if err != nil {
log.Errorf("[%s] config.Timeout err = %v", paramParts[1], err)
}
config.StartPeriod, err = time.ParseDuration(paramParts[2])
if err != nil {View on GitHub (pinned to 81940d17fa)
Solutions
- Inspect the quoted data in the error and rewrite the HEALTHCHECK entry in image history/config metadata to the 4-parameter quoted form the parser expects.
- If the source image's HEALTHCHECK is shell-form, drop the HEALTHCHECK metadata or convert it to JSON/exec form before running the reverse builder.
- If the image is trusted and you only need the rest of the Dockerfile, pre-process the history to remove the malformed HEALTHCHECK instruction.
Example fix
// before (shell form in history) HEALTHCHECK CMD curl -f http://localhost/ || exit 1 // after (exec/JSON form with all parameters) HEALTHCHECK ["CMD", "curl", "-f", "http://localhost/"]
Defensive patterns
Strategy: validation
Validate before calling
// validate HEALTHCHECK history entry before reverse-building
func validHealthcheck(hist string) bool {
i := strings.Index(hist, "HEALTHCHECK")
if i < 0 { return true }
parts := strings.SplitN(strings.TrimSpace(hist[i+len("HEALTHCHECK"):]), " ", 4)
return len(parts) == 4
} Try / catch
if _, cfgErr := builder.Run(...); cfgErr != nil && strings.Contains(cfgErr.Error(), "malformed HEALTHCHECK") {
// fall back: strip HEALTHCHECK from history and retry
} Prevention
- Ensure image history HEALTHCHECK entries use the 4-parameter quoted/exec form
- Never hand-edit image config history strings
- Pre-scan image history for HEALTHCHECK instructions before reverse-engineering
When it happens
Trigger: Parsing a HEALTHCHECK instruction whose parameter section has fewer than 4 space-separated quoted parameters, e.g. `HEALTHCHECK CMD curl -f http://localhost/ || exit 1` without the surrounding JSON-array form (`HEALTHCHECK ["CMD", "curl", ...]`-style reconstruction) or with parameters collapsed onto fewer tokens, when calling the reverse Dockerfile builder (Run/NewBasicImageBuilder).
Common situations: Reconstructing Dockerfiles from OCI image history where the original HEALTHCHECK used shell form instead of exec/JSON form; hand-edited image history strings; images built by tooling that emitted non-standard HEALTHCHECK metadata.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- expected retries (%s) to be an escape sequence
- got an invalid escape sequence: %s
- when using JSON array syntax, arrays must be comprised of st
- unknown instruction
- only one escape parser directive can be used
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/71ad31599a5df2ad.
Report an issue: GitHub.