hashicorp/packer · error

attestation predicate type %q does not match expected %q

Error message

attestation predicate type %q does not match expected %q

What it means

When the verification policy specifies a PredicateType, verifyPolicy requires the attestation's `predicateType` to match it exactly. This error means the attestation is a valid in-toto statement but describes a different predicate than the policy allows.

Source

Thrown at internal/attestation/verify.go:231

			return true
		}
	}

	return false
}

func verifyPolicy(payload []byte, policy VerificationPolicy) (*internalprovenance.Statement, error) {
	var statement internalprovenance.Statement
	if err := json.Unmarshal(payload, &statement); err != nil {
		return nil, fmt.Errorf("decode attestation statement: %w", err)
	}

	if statement.Type != internalprovenance.StatementType {
		return nil, fmt.Errorf("unexpected attestation statement type %q", statement.Type)
	}

	if policy.PredicateType != "" && statement.PredicateType != policy.PredicateType {
		return nil, fmt.Errorf("attestation predicate type %q does not match expected %q", statement.PredicateType, policy.PredicateType)
	}

	if policy.ArtifactPath != "" {
		if err := verifyArtifactSubject(statement.Subject, policy.ArtifactPath); err != nil {
			return nil, err
		}
	}

	if policy.BuilderID != "" || policy.SourceURI != "" {
		if statement.PredicateType != internalprovenance.SLSAProvenanceV1PredicateType {
			return nil, fmt.Errorf("builder and source policy checks require predicate type %q, got %q", internalprovenance.SLSAProvenanceV1PredicateType, statement.PredicateType)
		}

		var typedStatement struct {
			Type          string                                     `json:"_type"`
			Subject       []internalprovenance.Subject               `json:"subject"`
			PredicateType string                                     `json:"predicateType"`
			Predicate     internalprovenance.SLSAProvenancePredicate `json:"predicate"`

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Compare the attestation's predicateType with the policy's expected PredicateType and align them (the error message shows both).
  2. Update the policy PredicateType to the predicate actually produced (e.g. switch to v0.2 URI if that is what your builder emits).
  3. Regenerate the attestation with a builder that emits the required predicate version.
  4. If you accept multiple predicate types, run verification once per expected PredicateType instead of a single strict policy.

Example fix

// policy before
policy.PredicateType = "https://slsa.dev/provenance/v1" // attestation has v0.2
// after (align with produced attestation)
policy.PredicateType = "https://slsa.dev/provenance/v0.2"
Defensive patterns

Strategy: validation

Validate before calling

var s struct{ PredicateType string `json:"predicateType"` }
_ = json.Unmarshal(payload, &s)
if policy.PredicateType != "" && s.PredicateType != policy.PredicateType {
	return fmt.Errorf("attestation is %s, policy expects %s", s.PredicateType, policy.PredicateType)
}

Try / catch

_, err := VerifyAttestationFile(path, policy)
if err != nil && strings.Contains(err.Error(), "does not match expected") {
	// inspect both predicateType URIs; realign policy or regenerate attestation
}

Prevention

When it happens

Trigger: VerifyAttestationFile called with a policy whose PredicateType is set (e.g. SLSA provenance v1) while the file's predicateType is something else (e.g. a vulnerability-scan or SBOM predicate).

Common situations: Pointing a provenance-verification policy at an SBOM attestation; policy configured for https://slsa.dev/provenance/v1 while the build system still emits v0.2 provenance; copy-pasted policy referencing the wrong predicate URI.

Related errors


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/3bde0458e819398f. Report an issue: GitHub.