chatwoot / chatwoot/chatwoot-flutter-sdk

Enabling "Enforce User Identity Validation" cause ChatwootClientException in SDK

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
85
Forks
165
PR merge metrics
No merged PRs in 30d

Description

Hi,
I have been trying to enforce user identity validation in chatwoot SDK but getting this exception -

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Instance of 'ChatwootClientException'
E/flutter (13424): #0 ChatwootClientAuthServiceImpl.createNewContact (package:chatwoot_client_sdk/data/remote/service/chatwoot_client_auth_service.dart:52:7)
E/flutter (13424):
E/flutter (13424): #1 ChatwootClientApiInterceptor.onRequest. (package:chatwoot_client_sdk/data/remote/service/chatwoot_client_api_interceptor.dart:37:19)
E/flutter (13424):
E/flutter (13424): #2 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter (13424):
E/flutter (13424): #3 ChatwootClientApiInterceptor.onRequest (package:chatwoot_client_sdk/data/remote/service/chatwoot_client_api_interceptor.dart:29:5)
E/flutter (13424):

When I dig deeper in the exception, I realized that this exception is caused when createNewContact function is trying to Create Contact using createContactAPI in chatwoot_client_auth_service.dart file. the Exception is -
DioError [DioErrorType.response]: Http status error [500]

this exception came because createConatctAPI expects "identifier_hash" attribute but SDK pass "identifierHash" attribute instead.
since the ChatwootUser function is written this way -
ChatwootUser(
{this.identifier,
this.identifierHash,
this.name,
this.email,
this.avatarUrl,
this.customAttributes});

and client ContactsAPI expects payload in this format -
{
"identifier": "string",
"identifier_hash": "string",
"email": "string",
"name": "string",
"phone_number": "string",
"avatar_url": "string",
"custom_attributes": { }
}

What should I do in this case.?
I am attaching postman screenshots also to describe the issue clearly

Error Image
![image](https://user-images.githubusercontent.com/39898463/224267067-0ac64137-9cc6-42a5-8c49-9b6c1ed85d27.png)

Success Event Image
![image](https://user-images.githubusercontent.com/39898463/224267354-72f98926-c94e-47c9-a9d0-49417153d455.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in data/remote/service/chatwoot_client_auth_service.dart at createNewContact and the createContactAPI request, then inspect how ChatwootUser fields are serialized. Verify that the contact payload uses the API's identifier_hash and other snake_case names, and confirm that Enforce User Identity Validation no longer produces the reported 500 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
api, authentication, mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.