{"record":{"id":"1759da48dbb6108e","repo":"hashicorp/nomad","slug":"can-not-diff-tasks-with-different-names-q-and-q","errorCode":null,"errorMessage":"can not diff tasks with different names: %q and %q","messagePattern":"can not diff tasks with different names: %q and %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/diff.go","lineNumber":466,"sourceCode":"\n\tif t == nil && other == nil {\n\t\treturn diff, nil\n\t} else if t == nil {\n\t\tt = &Task{}\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 = &Task{}\n\t\tdiff.Type = DiffTypeDeleted\n\t\tdiff.Name = t.Name\n\t\toldPrimitiveFlat = flatmap.Flatten(t, filter, true)\n\t} else {\n\t\tif !reflect.DeepEqual(t, other) {\n\t\t\tdiff.Type = DiffTypeEdited\n\t\t}\n\t\tif t.Name != other.Name {\n\t\t\treturn nil, fmt.Errorf(\"can not diff tasks with different names: %q and %q\", t.Name, other.Name)\n\t\t}\n\t\tdiff.Name = other.Name\n\t\toldPrimitiveFlat = flatmap.Flatten(t, filter, true)\n\t\tnewPrimitiveFlat = flatmap.Flatten(other, filter, true)\n\t}\n\n\t// Diff the primitive fields.\n\tdiff.Fields = fieldDiffs(oldPrimitiveFlat, newPrimitiveFlat, false)\n\n\t// Constraints diff\n\tconDiff := primitiveObjectSetDiff(\n\t\tinterfaceSlice(t.Constraints),\n\t\tinterfaceSlice(other.Constraints),\n\t\t[]string{\"str\"},\n\t\t\"Constraint\",\n\t\tcontextual)\n\tif conDiff != nil {\n\t\tdiff.Objects = append(diff.Objects, conDiff...)","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/diff.go#L448-L484","documentation":"Task.Diff refuses to compare two non-nil tasks with different names; task diffs are only defined for the same task name across job versions.","triggerScenarios":"Thrown at nomad/structs/diff.go:466 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Diff tasks with matching names","Represent added/deleted tasks with a nil side instead of different 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"}