{"id":"e303bb5f075a098c","repo":"docker/cli","slug":"got-wrong-object-to-inspect","errorCode":null,"errorMessage":"got wrong object to inspect","messagePattern":"got wrong object to inspect","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/formatter.go","lineNumber":235,"sourceCode":"\t}\n\treturn networkNames\n}\n\n// inspectFormatWrite renders the context for a list of services\nfunc inspectFormatWrite(fmtCtx formatter.Context, refs []string, getRef, getNetwork inspect.GetRefFunc) error {\n\tif fmtCtx.Format != serviceInspectPrettyTemplate {\n\t\treturn inspect.Inspect(fmtCtx.Output, refs, string(fmtCtx.Format), getRef)\n\t}\n\n\treturn fmtCtx.Write(&serviceInspectContext{}, func(format func(subContext formatter.SubContext) error) error {\n\t\tfor _, ref := range refs {\n\t\t\tserviceI, _, err := getRef(ref)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tservice, ok := serviceI.(swarm.Service)\n\t\t\tif !ok {\n\t\t\t\treturn errors.New(\"got wrong object to inspect\")\n\t\t\t}\n\t\t\tif err := format(&serviceInspectContext{\n\t\t\t\tService:      service,\n\t\t\t\tnetworkNames: resolveNetworks(service, getNetwork),\n\t\t\t}); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n}\n\ntype serviceInspectContext struct {\n\tswarm.Service\n\tformatter.SubContext\n\n\t// networkNames is a map from network IDs (as found in\n\t// Networks[x].Target) to network names.","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/service/formatter.go#L217-L253","documentation":"Internal type-assertion failure in the service pretty-print path: inspectFormatWrite expects each object returned by the getRef callback to be a swarm.Service, and errors if the assertion `serviceI.(swarm.Service)` fails. It indicates the inspect plumbing handed a non-Service value (or a pointer instead of a value) to the service formatter — a programming/integration bug rather than a user mistake.","triggerScenarios":"Only reachable when the pretty template is active and getRef returns something other than a swarm.Service value — e.g. custom code embedding the docker/cli packages passes *swarm.Service or another type, or an API-version mismatch causes decoding into a different type.","commonSituations":"Developers vendoring github.com/docker/cli and wiring their own GetRefFunc into inspectFormatWrite, or version skew between cli and moby client libraries where the inspect result type changed (value vs pointer).","solutions":["If embedding the cli packages, ensure the getRef callback returns swarm.Service by value, not *swarm.Service or another type.","Align docker/cli and moby/moby client library versions so inspect result types match.","If hit from the stock docker binary, report it as a bug with `docker version` output — end users should never see this."],"exampleFix":"// before (custom getRef)\nreturn &res.Service, res.Raw, err\n// after\nreturn res.Service, res.Raw, err // value, matches serviceI.(swarm.Service)","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","swarm","services","type-assertion","internal-error"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}