{"record":{"id":"07cebfdb63542ad4","repo":"OpenNHP/opennhp","slug":"failed-to-get-agent-unique-id-v","errorCode":null,"errorMessage":"failed to get agent unique id: %v","messagePattern":"failed to get agent unique id: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/core/wasm/engine/host.go","lineNumber":72,"sourceCode":"\t}\n\n\tvar buf bytes.Buffer\n\tw := zlib.NewWriter(&buf)\n\t_, err = w.Write(body)\n\tw.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to compress response body: %w\", err)\n\t}\n\n\tcompressedBody := buf.Bytes()\n\n\treturn compressedBody, nil\n}\n\nfunc GetEvidenceWithAgentUuid() ([]byte, error) {\n\tagentUniqueId, err := CalculateAgentUniqueId()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get agent unique id: %v\", err)\n\t}\n\n\tevidence := map[string]any{\n\t\t\"test_purpose\":  \"this evidence is for testing purposes only\",\n\t\t\"measure\":       agentUniqueId,\n\t\t\"serial_number\": agentUniqueId,\n\t}\n\n\tevidenceBytes, err := json.Marshal(evidence)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal evidence: %v\", err)\n\t}\n\n\tvar buf bytes.Buffer\n\tw := zlib.NewWriter(&buf)\n\t_, err = w.Write(evidenceBytes)\n\tw.Close()\n\tif err != nil {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/core/wasm/engine/host.go#L54-L90","documentation":"Raised by GetEvidenceWithAgentUuid when the helper CalculateAgentUniqueId returns an error. The fallback evidence path builds a synthetic test-purpose evidence object keyed on the agent's unique id; without that id the evidence cannot be constructed, so the failure of the underlying id calculation is wrapped and propagated to the WASM guest.","triggerScenarios":"Calling GetEvidence (test/fallback path) when CalculateAgentUniqueId fails — typically because required machine/host identity sources (hostname, machine-id file, MAC address, or crypto/rand) are unavailable.","commonSituations":"Running the agent in a minimal container without /etc/machine-id or hostname configured; restricted filesystem permissions; crypto entropy source unavailable at boot.","solutions":["Inspect the wrapped inner error to see which identity source failed","Ensure the container/host exposes /etc/machine-id (or systemd-machine-id-setup) and a resolvable hostname","Fix file permissions on the identity files or configure an explicit agent id in the agent config"],"exampleFix":"// before\nagentUniqueId, err := CalculateAgentUniqueId()\nif err != nil {\n    return nil, fmt.Errorf(\"failed to get agent unique id: %v\", err)\n}\n// after\nagentUniqueId, err := CalculateAgentUniqueId()\nif err != nil {\n    return nil, fmt.Errorf(\"failed to get agent unique id: %v (check /etc/machine-id and hostname)\", err)\n}","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(\"/etc/machine-id\"); err != nil {\n    return errors.New(\"host identity unavailable: /etc/machine-id missing\")\n}","typeGuard":null,"tryCatchPattern":"ev, err := engine.GetEvidence()\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to get agent unique id\") {\n        return fmt.Errorf(\"cannot build fallback evidence: %w\", err)\n    }\n}","preventionTips":["Ensure /etc/machine-id exists in container images","Set a hostname at container start","Pre-seed an explicit agent id in config for minimal environments"],"tags":["identity","agent","uuid"],"backgroundTag":"missing-required-config-field","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"}