{"record":{"id":"664b559af6072d71","repo":"hashicorp/nomad","slug":"can-not-diff-jobs-with-different-ids-q-and-q","errorCode":null,"errorMessage":"can not diff jobs with different IDs: %q and %q","messagePattern":"can not diff jobs with different IDs: %q and %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/diff.go","lineNumber":94,"sourceCode":"\tvar oldPrimitiveFlat, newPrimitiveFlat map[string]string\n\tfilter := []string{\"ID\", \"Status\", \"StatusDescription\", \"Version\", \"Stable\", \"CreateIndex\",\n\t\t\"ModifyIndex\", \"JobModifyIndex\", \"Update\", \"SubmitTime\", \"NomadTokenID\", \"VaultToken\"}\n\n\tif j == nil && other == nil {\n\t\treturn diff, nil\n\t} else if j == nil {\n\t\tj = &Job{}\n\t\tdiff.Type = DiffTypeAdded\n\t\tnewPrimitiveFlat = flatmap.Flatten(other, filter, true)\n\t\tdiff.ID = other.ID\n\t} else if other == nil {\n\t\tother = &Job{}\n\t\tdiff.Type = DiffTypeDeleted\n\t\toldPrimitiveFlat = flatmap.Flatten(j, filter, true)\n\t\tdiff.ID = j.ID\n\t} else {\n\t\tif j.ID != other.ID {\n\t\t\treturn nil, fmt.Errorf(\"can not diff jobs with different IDs: %q and %q\", j.ID, other.ID)\n\t\t}\n\n\t\toldPrimitiveFlat = flatmap.Flatten(j, filter, true)\n\t\tnewPrimitiveFlat = flatmap.Flatten(other, filter, true)\n\t\tdiff.ID = other.ID\n\t}\n\n\t// Diff the primitive fields.\n\tdiff.Fields = fieldDiffs(oldPrimitiveFlat, newPrimitiveFlat, false)\n\n\t// Datacenters diff\n\tif setDiff := stringSetDiff(j.Datacenters, other.Datacenters, \"Datacenters\", contextual); setDiff != nil && setDiff.Type != DiffTypeNone {\n\t\tdiff.Objects = append(diff.Objects, setDiff)\n\t}\n\n\t// Constraints diff\n\tconDiff := primitiveObjectSetDiff(\n\t\tinterfaceSlice(j.Constraints),","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/diff.go#L76-L112","documentation":"Job.Diff refuses to compare two non-nil jobs whose IDs differ; diffing is only defined for two versions of the same job ID (nil on either side means added/deleted).","triggerScenarios":"Thrown at nomad/structs/diff.go:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass job versions with the same ID to Diff","Use nil for the old/new job to express add/delete instead of mismatched IDs"],"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"}