(raw json.RawMessage)
| 1827 | } |
| 1828 | |
| 1829 | func chatDebugAttempts(raw json.RawMessage) []map[string]any { |
| 1830 | if len(raw) == 0 { |
| 1831 | return nil |
| 1832 | } |
| 1833 | |
| 1834 | var attempts []map[string]any |
| 1835 | if err := json.Unmarshal(raw, &attempts); err != nil { |
| 1836 | return []map[string]any{{ |
| 1837 | "error": "malformed attempts payload", |
| 1838 | "parse_error": err.Error(), |
| 1839 | "raw": string(raw), |
| 1840 | }} |
| 1841 | } |
| 1842 | // Guard against JSON literal "null" which unmarshals successfully |
| 1843 | // but leaves the slice nil. The DB column is JSONB NOT NULL but |
| 1844 | // that only rejects SQL NULL, not JSONB null. |
| 1845 | if attempts == nil { |
| 1846 | return []map[string]any{} |
| 1847 | } |
| 1848 | return attempts |
| 1849 | } |
| 1850 | |
| 1851 | // rawJSONObject deserializes a JSON object payload for debug display. |
| 1852 | // If the payload is malformed, it returns a map with "error" and "raw" |
no test coverage detected