{"record":{"id":"5a953b6a77d846ec","repo":"OpenNHP/opennhp","slug":"failed-to-create-csv-verifier-v","errorCode":null,"errorMessage":"failed to create csv verifier: %v","messagePattern":"failed to create csv verifier: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/core/verifier/verifier.go","lineNumber":88,"sourceCode":"\t}\n\n\tvar evidence map[string]any\n\n\terr = json.Unmarshal(evidenceBytes, &evidence)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal evidence: %v\", err)\n\t}\n\n\tvar verifier Verifier\n\n\tif _, ok := evidence[\"test_purpose\"]; ok {\n\t\tverifier, err = NewFallbackVerifier(evidenceBytes)\n\t} else {\n\t\tverifier, err = csv.NewAttestation(string(evidenceBytes))\n\t}\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create csv verifier: %v\", err)\n\t} else {\n\t\treturn verifier, nil\n\t}\n}\n","sourceCodeStart":70,"sourceCodeEnd":93,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/core/verifier/verifier.go#L70-L93","documentation":"After sniffing for \"test_purpose\", NewVerifier builds either a FallbackVerifier or a CoCo (csv) attestation verifier; this wraps any construction failure from either path. Note the fallback path's error is also mislabeled as \"csv verifier\" here.","triggerScenarios":"FallbackVerifier path: decompressed evidence contains \"test_purpose\" key but fails FallbackVerifier json.Unmarshal (e.g. \"measure\" or \"serial_number\" present but non-string, or JSON is an array). CSV path: csv.NewAttestation rejects the CoCo attestation structure (missing/invalid fields, signature verification prep failure).","commonSituations":"Test evidence produced by GetEvidenceWithAgentUuid with a non-string agent unique id; malformed CoCo attestation JSON from a misconfigured attestation agent; upgrading the CoCo evidence format so older parsers fail.","solutions":["Read the wrapped inner error (%v chain) to see which constructor actually failed","If using test evidence, confirm the JSON has string-typed \"test_purpose\", \"measure\", and \"serial_number\" fields","For CoCo evidence, validate the attestation report structure against the current csv.NewAttestation expectations and check the attestation-agent version"],"exampleFix":"// before\nif err != nil {\n    return nil, fmt.Errorf(\"failed to create csv verifier: %v\", err)\n}\n// after\nif err != nil {\n    return nil, fmt.Errorf(\"failed to create verifier (csv=%v, not test evidence): %w\", evidence[\"test_purpose\"] == nil, err)\n}","handlingStrategy":"try-catch","validationCode":"var probe map[string]any\nif err := json.Unmarshal(evidenceBytes, &probe); err != nil { return err }\nisTest := probe[\"test_purpose\"] != nil\nif isTest {\n    for _, k := range []string{\"measure\",\"serial_number\"} {\n        if _, ok := probe[k].(string); !ok { return fmt.Errorf(\"field %q must be a string\", k) }\n    }\n}","typeGuard":null,"tryCatchPattern":"v, err := verifier.NewVerifier(evidenceB64)\nif err != nil {\n    var ve *verifier.Error // or inspect wrapped chain with errors.As/Unwrap\n    if errors.As(err, &ve) { /* route by inner constructor error */ }\n    return fmt.Errorf(\"verifier construction failed: %w\", err)\n}","preventionTips":["Keep fallback evidence JSON strictly string-typed","Surface which constructor failed instead of always saying 'csv verifier'","Track CoCo evidence schema versions the csv package supports"],"tags":["attestation","verifier","csv","go"],"backgroundTag":"module-init-failed","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}