{"record":{"id":"8fd16f7e2578c7f0","repo":"hashicorp/nomad","slug":"can-not-diff-task-groups-with-different-names-q","errorCode":null,"errorMessage":"can not diff task groups with different names: %q and %q","messagePattern":"can not diff task groups with different names: %q and %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/diff.go","lineNumber":245,"sourceCode":"\n\tif tg == nil && other == nil {\n\t\treturn diff, nil\n\t} else if tg == nil {\n\t\ttg = &TaskGroup{}\n\t\tdiff.Type = DiffTypeAdded\n\t\tdiff.Name = other.Name\n\t\tnewPrimitiveFlat = flatmap.Flatten(other, filter, true)\n\t} else if other == nil {\n\t\tother = &TaskGroup{}\n\t\tdiff.Type = DiffTypeDeleted\n\t\tdiff.Name = tg.Name\n\t\toldPrimitiveFlat = flatmap.Flatten(tg, filter, true)\n\t} else {\n\t\tif !reflect.DeepEqual(tg, other) {\n\t\t\tdiff.Type = DiffTypeEdited\n\t\t}\n\t\tif tg.Name != other.Name {\n\t\t\treturn nil, fmt.Errorf(\"can not diff task groups with different names: %q and %q\", tg.Name, other.Name)\n\t\t}\n\t\tdiff.Name = other.Name\n\t\toldPrimitiveFlat = flatmap.Flatten(tg, filter, true)\n\t\tnewPrimitiveFlat = flatmap.Flatten(other, filter, true)\n\t}\n\n\t// ShutdownDelay diff\n\tif oldPrimitiveFlat != nil && newPrimitiveFlat != nil {\n\t\tif tg.ShutdownDelay == nil {\n\t\t\toldPrimitiveFlat[\"ShutdownDelay\"] = \"\"\n\t\t} else {\n\t\t\toldPrimitiveFlat[\"ShutdownDelay\"] = fmt.Sprintf(\"%d\", *tg.ShutdownDelay)\n\t\t}\n\t\tif other.ShutdownDelay == nil {\n\t\t\tnewPrimitiveFlat[\"ShutdownDelay\"] = \"\"\n\t\t} else {\n\t\t\tnewPrimitiveFlat[\"ShutdownDelay\"] = fmt.Sprintf(\"%d\", *other.ShutdownDelay)\n\t\t}","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/diff.go#L227-L263","documentation":"TaskGroup.Diff refuses to compare two non-nil task groups with different names; a diff is only meaningful between versions of the same named group.","triggerScenarios":"Thrown at nomad/structs/diff.go:245 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Diff task groups with matching names","Handle add/remove via a nil side rather than mismatched names"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}