{"record":{"id":"a572d2a5733082fc","repo":"kubesphere/kubesphere","slug":"yamllist-and-yamltemplist-not-equal","errorCode":null,"errorMessage":"yamlList and yamlTempList not equal","messagePattern":"yamlList and yamlTempList not equal","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/simple/client/application/helper.go","lineNumber":547,"sourceCode":"\tyamlTempList, err := ReadYaml(tempLate)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(yamlTempList) != len(yamlList) {\n\t\treturn nil, errors.New(\"yamlList and yamlTempList length not equal\")\n\t}\n\tfor idx := range yamlTempList {\n\t\t_, utd, err := GetInfoFromBytes(yamlList[idx], mapper)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\t_, utdTemp, err := GetInfoFromBytes(yamlTempList[idx], mapper)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif utdTemp.GetKind() != utd.GetKind() || utdTemp.GetAPIVersion() != utd.GetAPIVersion() {\n\t\t\treturn nil, errors.New(\"yamlList and yamlTempList not equal\")\n\t\t}\n\t\tif utd.GetNamespace() != ns {\n\t\t\treturn nil, errors.New(\"subresource must have same namespace with app release\")\n\t\t}\n\t}\n\treturn yamlList, nil\n}\n\nfunc GetUuid36(prefix string) string {\n\tid := idutils.GetIntId()\n\thd := hashids.NewData()\n\thd.Alphabet = idutils.Alphabet36\n\th, err := hashids.NewWithData(hd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ti, err := h.Encode([]int{int(id)})\n\tif err != nil {","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/kubesphere/kubesphere/blob/04a29b5c601470fa6bc2f2e92358dcb802a0d414/pkg/simple/client/application/helper.go#L529-L565","documentation":"ComplianceCheck compares each user resource YAML with its corresponding template YAML pairwise. When a pair has a different Kind or apiVersion, the resource does not match the template contract and this error is returned, indicating the app package's resources and templates are inconsistent.","triggerScenarios":"Pair idx of yamlList and yamlTempList parses successfully but utd.GetKind() or utd.GetAPIVersion() differs from the template's — e.g. template says apps/v1 Deployment while the resource YAML says extensions/v1beta1 Deployment, or the documents are ordered differently so pairs compare against the wrong template.","commonSituations":"Kubernetes API version migrations (extensions/v1beta1 → apps/v1, batch/v1beta1 → batch/v1 jobs/cronjobs); hand-edited app packages; reordered YAML documents causing pairwise misalignment; templates generated from an older cluster version.","solutions":["Align each resource YAML's Kind and apiVersion with its template counterpart","Update deprecated apiVersions (e.g. extensions/v1beta1 to apps/v1) in both files","Keep document order identical in resource and template YAML lists","Re-validate the package with ComplianceCheck after any edit"],"exampleFix":"// before\nkind: Deployment\napiVersion: extensions/v1beta1\n// after\nkind: Deployment\napiVersion: apps/v1","handlingStrategy":"validation","validationCode":"for i, doc := range yamlDocs {\n\tif doc.Kind != templateDocs[i].Kind || doc.APIVersion != templateDocs[i].APIVersion {\n\t\treturn fmt.Errorf(\"doc %d: %s/%s does not match template %s/%s\",\n\t\t\ti, doc.APIVersion, doc.Kind, templateDocs[i].APIVersion, templateDocs[i].Kind)\n\t}\n}","typeGuard":null,"tryCatchPattern":"yamls, err := ComplianceCheck(yamlList, tempLate, ns, mapper)\nif err != nil {\n\tif strings.Contains(err.Error(), \"yamlList and yamlTempList not equal\") {\n\t\treturn fmt.Errorf(\"Kind/apiVersion mismatch between resources and templates; update deprecated apiVersions: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Migrate deprecated apiVersions (extensions/v1beta1, batch/v1beta1) to current ones in both files","Keep resource and template YAML documents in identical order","Lint app packages against the target Kubernetes version before upload","Never edit one side (resource vs template) without the other"],"tags":["yaml","openpitrix","api-version","validation"],"backgroundTag":"yaml-kind-apiversion-mismatch","analyzedSha":"04a29b5c601470fa6bc2f2e92358dcb802a0d414","analyzedAt":"2026-09-03T18:33:15.017Z","contentChangedAt":"2026-09-03T18:33:15.017Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}