{"record":{"id":"0ca4cc6e740955d6","repo":"sipeed/picoclaw","slug":"get-chat-by-contact-w","errorCode":null,"errorMessage":"get chat by contact: %w","messagePattern":"get chat by contact: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/deltachat/deltachat.go","lineNumber":631,"sourceCode":"\t}\n\traw, err := c.rpc.call(ctx, \"create_contact\", c.accountID, address, displayName)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"create contact: %w\", err)\n\t}\n\tvar contactID int64\n\tif err := json.Unmarshal(raw, &contactID); err != nil {\n\t\treturn 0, fmt.Errorf(\"create contact decode: %w\", err)\n\t}\n\tif contactID <= 0 {\n\t\treturn 0, fmt.Errorf(\"create contact returned empty id: %w\", channels.ErrSendFailed)\n\t}\n\treturn contactID, nil\n}\n\nfunc (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)","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/deltachat/deltachat.go#L613-L649","documentation":"Context wrapper in DeltaChatChannel.chatIDForContact around the 'get_chat_id_by_contact_id' JSON-RPC call: the DeltaChat core RPC failed, meaning no existing chat could be looked up for the contact. The call site treats this as fatal for contact resolution; a chatID of 0 (no chat yet) is NOT an error — that case falls through to chat creation.","triggerScenarios":"Thrown at pkg/channels/deltachat/deltachat.go:631 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the DeltaChat RPC server is running and the accountID is valid","Inspect the wrapped RPC error for method-level failures","Retry on transient transport errors to the RPC socket","Ensure the contact exists before resolving its chat"],"exampleFix":null,"handlingStrategy":"retry","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"}