{"record":{"id":"a373fca10224d6e0","repo":"OpenNHP/opennhp","slug":"error-fail-to-find-policyid-for-ztdoid-s","errorCode":null,"errorMessage":"Error: fail to find policyId for ztdoId %s.\n","messagePattern":"Error: fail to find policyId for ztdoId (.+?)\\.\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/agent/udpagent.go","lineNumber":1286,"sourceCode":"\t\tdefer a.dataAccessRefreshMutex.Unlock()\n\n\t\t// secondly check again\n\t\toutput, refreshSdp, decrypted = a.PreCheckDataAccess(ztdoId)\n\n\t\tif refreshSdp {\n\t\t\toutput, err = a.RefreshDataAccess(ztdoId, decrypted, output)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Failed to refresh SDP: %s\", err.Error())\n\t\t\t}\n\t\t}\n\t}\n\n\t// inject data path to params\n\tparams[\"path\"] = output\n\n\tvar exist bool\n\tif policyId, exist = a.smartPolicyIdentifier[ztdoId]; !exist {\n\t\treturn nil, fmt.Errorf(\"Error: fail to find policyId for ztdoId %s.\\n\", ztdoId)\n\t}\n\n\ttaRes, err := a.CallTrustedApplication(taId, function, params, policyId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to call trusted application with error: %s\\n\", err.Error())\n\t} else {\n\t\tvar structResult map[string]any\n\n\t\terr := json.Unmarshal([]byte(taRes), &structResult)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"fail to unmarshal confidential computing result: %s\\n\", err.Error())\n\t\t}\n\n\t\treturn structResult, nil\n\t}\n}\n\nfunc (a *UdpAgent) PreCheckDataAccess(ztdoId string) (output string, refreshSdp bool, decrypted bool) {","sourceCodeStart":1268,"sourceCodeEnd":1304,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/agent/udpagent.go#L1268-L1304","documentation":"Before calling the trusted application the agent looks up the ztdoId in its smartPolicyIdentifier map; if no policyId is registered for that data object it returns this error. The policyId is required to route the confidential-computing request, so a missing mapping is fatal for the call.","triggerScenarios":"AccessData/TA call path where a.smartPolicyIdentifier[ztdoId] is absent — SDP never fetched, refresh skipped, or map populated under a different ztdoId.","commonSituations":"Querying a ztdo before its smart data policy was downloaded; ztdoId case/whitespace mismatch; agent restarted and in-memory policy map lost; earlier SDP refresh failure (error 34) left the map empty.","solutions":["Fix any upstream 'Failed to refresh SDP' error so RefreshDataAccess populates smartPolicyIdentifier","Verify the exact ztdoId string matches what the policy/data provider issued (trim whitespace/case)","Re-run PreCheckDataAccess / re-fetch the smart data policy before invoking the trusted application"],"exampleFix":"// before\ntaRes, err := a.CallTrustedApplication(taId, function, params, \"\")\n// after\npolicyId, ok := a.smartPolicyIdentifier[ztdoId]\nif !ok {\n    if _, err := a.RefreshDataAccess(ztdoId, decrypted, output); err != nil { return nil, err }\n    policyId = a.smartPolicyIdentifier[ztdoId]\n}\ntaRes, err := a.CallTrustedApplication(taId, function, params, policyId)","handlingStrategy":"validation","validationCode":"policyId, ok := a.smartPolicyIdentifier[ztdoId]\nif !ok {\n    return fmt.Errorf(\"no policy for %s; refresh SDP first\", ztdoId)\n}","typeGuard":null,"tryCatchPattern":"res, err := a.AccessData(ztdoId, taId, fn, params)\nif err != nil && strings.Contains(err.Error(), \"fail to find policyId\") {\n    // trigger SDP refresh path and retry\n    res, err = a.AccessData(ztdoId, taId, fn, params)\n}","preventionTips":["Always complete SDP refresh before TA calls; fix error 34 first","Normalize/trim ztdoId strings when storing and looking up","Persist policy map or refetch after agent restart"],"tags":["dhp","confidential-computing","lookup-failed"],"backgroundTag":"record-not-found","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"}