kubesphere/kubesphere · error

yamlList and yamlTempList not equal

Error message

yamlList and yamlTempList not equal

What it means

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.

Source

Thrown at pkg/simple/client/application/helper.go:547

	yamlTempList, err := ReadYaml(tempLate)
	if err != nil {
		return nil, err
	}

	if len(yamlTempList) != len(yamlList) {
		return nil, errors.New("yamlList and yamlTempList length not equal")
	}
	for idx := range yamlTempList {
		_, utd, err := GetInfoFromBytes(yamlList[idx], mapper)
		if err != nil {
			return nil, err
		}
		_, utdTemp, err := GetInfoFromBytes(yamlTempList[idx], mapper)
		if err != nil {
			return nil, err
		}
		if utdTemp.GetKind() != utd.GetKind() || utdTemp.GetAPIVersion() != utd.GetAPIVersion() {
			return nil, errors.New("yamlList and yamlTempList not equal")
		}
		if utd.GetNamespace() != ns {
			return nil, errors.New("subresource must have same namespace with app release")
		}
	}
	return yamlList, nil
}

func GetUuid36(prefix string) string {
	id := idutils.GetIntId()
	hd := hashids.NewData()
	hd.Alphabet = idutils.Alphabet36
	h, err := hashids.NewWithData(hd)
	if err != nil {
		panic(err)
	}
	i, err := h.Encode([]int{int(id)})
	if err != nil {

View on GitHub (pinned to 04a29b5c60)

Solutions

  1. Align each resource YAML's Kind and apiVersion with its template counterpart
  2. Update deprecated apiVersions (e.g. extensions/v1beta1 to apps/v1) in both files
  3. Keep document order identical in resource and template YAML lists
  4. Re-validate the package with ComplianceCheck after any edit

Example fix

// before
kind: Deployment
apiVersion: extensions/v1beta1
// after
kind: Deployment
apiVersion: apps/v1
Defensive patterns

Strategy: validation

Validate before calling

for i, doc := range yamlDocs {
	if doc.Kind != templateDocs[i].Kind || doc.APIVersion != templateDocs[i].APIVersion {
		return fmt.Errorf("doc %d: %s/%s does not match template %s/%s",
			i, doc.APIVersion, doc.Kind, templateDocs[i].APIVersion, templateDocs[i].Kind)
	}
}

Try / catch

yamls, err := ComplianceCheck(yamlList, tempLate, ns, mapper)
if err != nil {
	if strings.Contains(err.Error(), "yamlList and yamlTempList not equal") {
		return fmt.Errorf("Kind/apiVersion mismatch between resources and templates; update deprecated apiVersions: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kubesphere/kubesphere@04a29b5c60 (2026-09-03). Data as JSON: /api/errors/a572d2a5733082fc. Report an issue: GitHub.