{"record":{"id":"4ccda06eba245ea9","repo":"docker/compose","slug":"invalid-indentation-size-d","errorCode":null,"errorMessage":"invalid indentation size: %d","messagePattern":"invalid indentation size: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/viz.go","lineNumber":97,"sourceCode":"\t}\n\n\t// build graph\n\tgraphStr, _ := backend.Viz(ctx, project, api.VizOptions{\n\t\tIncludeNetworks:  opts.includeNetworks,\n\t\tIncludePorts:     opts.includePorts,\n\t\tIncludeImageName: opts.includeImageName,\n\t\tIndentation:      opts.indentationStr,\n\t})\n\n\tfmt.Println(graphStr)\n\n\treturn nil\n}\n\n// preferredIndentationStr returns a single string given the indentation preference\nfunc preferredIndentationStr(size int, useSpace bool) (string, error) {\n\tif size < 0 {\n\t\treturn \"\", fmt.Errorf(\"invalid indentation size: %d\", size)\n\t}\n\n\tindentationStr := \"\\t\"\n\tif useSpace {\n\t\tindentationStr = \" \"\n\t}\n\treturn strings.Repeat(indentationStr, size), nil\n}\n","sourceCodeStart":79,"sourceCodeEnd":106,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/viz.go#L79-L106","documentation":"Returned by preferredIndentationStr in `docker compose viz` when the --indentation flag value is negative. The function builds the indentation string with strings.Repeat, which panics on negative counts, so size < 0 is explicitly rejected first with this error. size == 0 is valid (no indentation).","triggerScenarios":"`docker compose viz --indentation -1`; passing --indentation 0 with --spaces is fine, but any negative integer hits the guard; script-computed indentation going negative.","commonSituations":"Typos or a shell variable that resolves to a negative number; users assuming negative means 'compact' output; piping a computed indent level that underflows in arithmetic.","solutions":["Pass a non-negative size: `docker compose viz --indentation 2 --spaces`.","Use 0 when you want no indentation.","Clamp computed values in scripts to >= 0."],"exampleFix":"# before\ndocker compose viz --indentation -1\n\n# after\ndocker compose viz --indentation 2 --spaces","handlingStrategy":"validation","validationCode":"INDENT=$(( ${INDENTATION:-2} )); (( INDENT < 0 )) && INDENT=0\ndocker compose viz --indentation \"$INDENT\" --spaces","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat indentation as unsigned; clamp computed values.","Use 0 for compact output instead of negatives."],"tags":["cli","viz","flags","validation","compose"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}