MCPcopy Index your code
hub / github.com/coder/coder / rawJSONObject

Function rawJSONObject

coderd/database/db2sdk/db2sdk.go:1855–1875  ·  view source on GitHub ↗

rawJSONObject deserializes a JSON object payload for debug display. If the payload is malformed, it returns a map with "error" and "raw" keys preserving the original content for diagnostics. Callers that consume the result programmatically should check for the "error" key.

(raw json.RawMessage)

Source from the content-addressed store, hash-verified

1853// keys preserving the original content for diagnostics. Callers that
1854// consume the result programmatically should check for the "error" key.
1855func rawJSONObject(raw json.RawMessage) map[string]any {
1856 if len(raw) == 0 {
1857 return nil
1858 }
1859
1860 var object map[string]any
1861 if err := json.Unmarshal(raw, &object); err != nil {
1862 return map[string]any{
1863 "error": "malformed debug payload",
1864 "parse_error": err.Error(),
1865 "raw": string(raw),
1866 }
1867 }
1868 // Guard against JSON literal "null" which unmarshals successfully
1869 // but leaves the map nil. The DB column is JSONB NOT NULL but
1870 // that only rejects SQL NULL, not JSONB null.
1871 if object == nil {
1872 return map[string]any{}
1873 }
1874 return object
1875}
1876
1877func nullRawJSONObject(raw pqtype.NullRawMessage) map[string]any {
1878 if !raw.Valid {

Callers 4

nullRawJSONObjectFunction · 0.85
ChatDebugRunSummaryFunction · 0.85
ChatDebugStepFunction · 0.85
ChatDebugRunDetailFunction · 0.85

Calls 2

UnmarshalMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected