{"record":{"id":"c80cbd9241722731","repo":"OpenNHP/opennhp","slug":"fail-to-call-trusted-application-with-error-s","errorCode":null,"errorMessage":"fail to call trusted application with error: %s\n","messagePattern":"fail to call trusted application with error: (.+?)\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/agent/udpagent.go","lineNumber":1291,"sourceCode":"\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) {\n\toutput = \"\"\n\n\t// Check whether the smart data policy needs to be refreshed\n\tif sdpRefreshTime, exist := a.smartDataPolicyRefreshTime[ztdoId]; exist {\n\t\tif time.Now().UnixNano()-sdpRefreshTime > SmartDataPolicyRefreshTime {","sourceCodeStart":1273,"sourceCodeEnd":1309,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/agent/udpagent.go#L1273-L1309","documentation":"CallTrustedApplication returned an error when the agent tried to execute the TA function with the resolved policyId; the agent wraps it as 'fail to call trusted application'. The underlying cause is inside the wrapped message — network to the TA/DB, wrong function/params, or policy rejection.","triggerScenarios":"AccessData flow with a valid policyId where a.CallTrustedApplication(taId, function, params, policyId) fails — unreachable TA endpoint, invalid taId/function name, rejected params, or DHP transport error.","commonSituations":"Wrong taId or function name; confidential-computing backend down; data path (params['path']) pointing to a missing temp file; authentication with the TA expired.","solutions":["Read the wrapped inner error (%s) for the actual cause","Verify taId, function name, and params against the TA's published interface","Check connectivity/credentials to the trusted application / nhp-db and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if taId == \"\" || function == \"\" || policyId == \"\" {\n    return fmt.Errorf(\"taId, function and policyId are required before TA call\")\n}","typeGuard":null,"tryCatchPattern":"res, err := a.AccessData(ztdoId, taId, fn, params)\nif err != nil && strings.Contains(err.Error(), \"fail to call trusted application\") {\n    log.Errorf(\"TA call failed: %v\", err) // inner cause is embedded\n    // check TA endpoint health / credentials before retry\n}","preventionTips":["Health-check the TA/db endpoint before confidential computing calls","Validate taId and function names against the TA interface registry","Ensure params['path'] points to an existing readable file"],"tags":["network","dhp","trusted-application","confidential-computing"],"backgroundTag":"upstream-api-error","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"}