{"record":{"id":"56b96a0667b2a4fe","repo":"sipeed/picoclaw","slug":"create-chat-by-contact-decode-w","errorCode":null,"errorMessage":"create chat by contact decode: %w","messagePattern":"create chat by contact decode: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/deltachat/deltachat.go","lineNumber":646,"sourceCode":"func (c *DeltaChatChannel) chatIDForContact(ctx context.Context, contactID int64) (int64, error) {\n\traw, err := c.rpc.call(ctx, \"get_chat_id_by_contact_id\", c.accountID, contactID)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"get chat by contact: %w\", err)\n\t}\n\tchatID, err := decodeOptionalInt64(raw, \"get chat by contact\")\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif chatID > 0 {\n\t\treturn chatID, nil\n\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","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/deltachat/deltachat.go#L628-L664","documentation":"Error \"create chat by contact decode: %w\" thrown in sipeed/picoclaw.","triggerScenarios":"Thrown at pkg/channels/deltachat/deltachat.go:646 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}