{"record":{"id":"b438fec331278fd5","repo":"JuliusBrussee/caveman","slug":"marshal-session-value-artifact-w","errorCode":null,"errorMessage":"marshal session-value artifact: %w","messagePattern":"marshal session-value artifact: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/routing/session_value.go","lineNumber":148,"sourceCode":"}\n\ntype SessionValuePrediction struct {\n\tActionID                string\n\tRewardProbability       float64\n\tQualityLCB              float64\n\tExpectedResidualCostUSD float64\n\tExpectedCostUSD         float64\n\tCostUCBUSD              float64\n\tExpectedCorrectiveTurns float64\n\tEscalationProbability   float64\n\tQualityUncertainty      float64\n}\n\nfunc ComputeSessionValueArtifactHash(artifact SessionValuePolicyArtifact) (string, error) {\n\tartifact.ArtifactHash = \"\"\n\traw, err := json.Marshal(artifact)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"marshal session-value artifact: %w\", err)\n\t}\n\tsum := sha256.Sum256(raw)\n\treturn \"sha256:\" + hex.EncodeToString(sum[:]), nil\n}\n\nfunc SealSessionValueArtifact(artifact SessionValuePolicyArtifact) (SessionValuePolicyArtifact, error) {\n\thash, err := ComputeSessionValueArtifactHash(artifact)\n\tif err != nil {\n\t\treturn SessionValuePolicyArtifact{}, err\n\t}\n\tartifact.ArtifactHash = hash\n\treturn artifact, nil\n}\n\nfunc ValidateSessionValueArtifact(artifact SessionValuePolicyArtifact, organizationID, projectID, candidatePoolHash string, now time.Time) error {\n\tif artifact.Schema != SessionValueArtifactSchema || artifact.StateSchemaVersion != SessionValueStateSchema {\n\t\treturn errors.New(\"session-value artifact schema mismatch\")\n\t}","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/proxy/routing/session_value.go#L130-L166","documentation":"ComputeSessionValueArtifactHash failed to JSON-marshal the session-value policy artifact while computing its canonical hash (the ArtifactHash field is zeroed first so the hash is self-consistent). Marshal failures here indicate non-serializable field types (NaN/Inf floats are the usual cause), not bad input data from callers.","triggerScenarios":"Thrown at proxy/routing/session_value.go:148 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure all numeric fields of the artifact are finite (no NaN or +Inf) before sealing","Fix the artifact-producing pipeline if it can emit non-serializable values"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}