{"record":{"id":"32510a45b5947ea0","repo":"sipeed/picoclaw","slug":"s-decode-w","errorCode":null,"errorMessage":"%s decode: %w","messagePattern":"(.+?) decode: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/deltachat/deltachat.go","lineNumber":657,"sourceCode":"\t}\n\n\traw, err = c.rpc.call(ctx, \"create_chat_by_contact_id\", c.accountID, contactID)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"create chat by contact: %w\", err)\n\t}\n\tif err := json.Unmarshal(raw, &chatID); err != nil {\n\t\treturn 0, fmt.Errorf(\"create chat by contact decode: %w\", err)\n\t}\n\tif chatID <= 0 {\n\t\treturn 0, fmt.Errorf(\"create chat by contact returned empty id: %w\", channels.ErrSendFailed)\n\t}\n\treturn chatID, nil\n}\n\nfunc decodeOptionalInt64(raw json.RawMessage, label string) (int64, error) {\n\tvar id *int64\n\tif err := json.Unmarshal(raw, &id); err != nil {\n\t\treturn 0, fmt.Errorf(\"%s decode: %w\", label, err)\n\t}\n\tif id == nil {\n\t\treturn 0, nil\n\t}\n\treturn *id, nil\n}\n\nfunc (c *DeltaChatChannel) resolveAliasChatID(ctx context.Context, target string) (int64, error) {\n\tfor _, query := range aliasQueries(target) {\n\t\tcontacts, err := c.findMatchingContacts(ctx, query)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tif len(contacts) == 1 {\n\t\t\treturn c.chatIDForContact(ctx, contacts[0].ID)\n\t\t}\n\t\tif len(contacts) > 1 {\n\t\t\treturn 0, ambiguousRecipientError(target, contactRecipientLabels(contacts))","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/deltachat/deltachat.go#L639-L675","documentation":"Generic decode helper in decodeOptionalInt64: the raw JSON-RPC payload failed to unmarshal into *int64 for the labeled method (the %s in the message, e.g. 'get chat by contact'). Because the target is a pointer type, a JSON null decodes to nil (no chat) without error — this error only fires when the payload is genuinely the wrong shape (string, object, array).","triggerScenarios":"Thrown at pkg/channels/deltachat/deltachat.go:657 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the raw payload alongside the label to identify the shape mismatch","Align the decode target with the DeltaChat core's actual response format","Handle null explicitly (nil pointer) before decoding when absent values are meaningful","Pin a core version whose RPC response shapes match this decoder"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}