Couchbase Lite android replication FORBIDDEN error

When trying to sync between mobile and sync-gateway, how to capture FORBIDDEN status errors as callback? There is only change listener available and it does not get error callback but I can see logs from cb android library like this,

W/Sync: error=forbidden, id=332444fa-0e81-4896-a171-8e1510ffc938, reason=Unknown document type, status=403}: _bulk_docs got an error: com.couchbase.lite.replicator.PusherInternal

I posted this issue in github ( and @hideki responded,
“you could set ChangeListener to the replicator, and check the value of ChangeEvent.getError().”

But even getError returns null always when the above log is printed.
I think it is because 403 errors are eaten up here,

Log.w(TAG, “%s: _bulk_docs got an error: %s”, item, this);
// 403/Forbidden means validation failed; don’t treat it as an error
// because I did my job in sending the revision. Other statuses are
// actual replication errors.

Is there any other way to capture sync-gateway FORBIDDEN 403 errors in replication object? Thanks!

Hi @bharath,

As CBL is open source, you could clone from github. You could customize Replicator codes as you want.

Hope this helps you.

Hi @hideki ,
Thanks a lot for responding again on this forum. Can you recommend how to handle validation errors from client side if a document fails to sync because of 403 errors?

With current implementation (spec), 403/Forbidden error during push replication is skipped. You could set Exception to `e variable. Could you please do some experiment by yourself?

Sure. So I guess only way to solve this is by forking and adding my changes to pass Forbidden errors. Thanks :slight_smile: