Question

Error: Unsuccessful response from data-sync: network [object Object]

  • 16 February 2024
  • 11 replies
  • 91 views

Badge +2

Hello,

I face the following issue when I try to call an action from my data connector. I think I followed all the necessary steps to make it work.

 

I well start the demon based on the debug-server.ts file :

 

 

I well declare it in the manifest

​​​​

I well defined the asynchronous actions 

 

Here is the definition of the action : 

 

Can someone help ?

 


Comments

Userlevel 1
Badge

Hi Guillaume,

 

Sorry to hear you’re having trouble with the data connector. It seems like the request probably isn’t making it to your data connector. Could you share with me the code you’re using to send the data action from your editor extension?

Also, if you open the network tab of your browser developer tools and find the request going to /asynchronousAction it might have a more useful error message in the response. Would you mind sharing that as well?

 

Alex

Badge +2

Hi @ablackburn , 

Here is the code I use to call the data action : 

 

I will have a look on the network tab to see if I see some hints about the issue

Badge +2

@ablackburn  Here is the network tab result 

 

Userlevel 1
Badge

Hi Guillaume,

 

From the second screenshot you sent it looks like your data connector is returning a 403 which indicates to me something is going on with the credential we’re trying to send on the network request to the data connector.

 

Have you uploaded your package to the developer dashboard and added a client id and secret for your OAuth provider? 

 

Alex

Badge +2

@ablackburn I confirm you that I uploaded the package and added the client id and secret for the OAuth provider.

As you can see in my first screenshots, in the data connector, I only put a console.log() just to test if it works or not.

I don’t understand why I can’t see the log in the console

Userlevel 1
Badge

Hi Guillaume, I've been looking in further and I believe I misspoke. I don’t actually think we're making any request to your data connector.

 

Have you ever been sent through the flow which sends you to the OAuth provider, and asks for permission to let your Lucid extension access the data in that system?

The basic process we go through before the request gets to your data connector is:

  1. Send a request from your extension to Lucid’s servers
  2. Lucid’s servers look up the correct OAuth credential to go with that request
    • If the user hasn't yet authorized the extension, they should get redirected to the third party to authorize the extension.
  3. Lucid's servers send the request to your data connector with the OAuth credential
    • If you're developing locally, we proxy this request through your browser using a websocket so we can hit your localhost address.


I believe we're getting stuck on step 2. I think we might have a bug in the flow that sends you to the OAuth provider when you're developing locally. I’m still looking into the details there.

 

In the meantime, my suggestion would be to upload and install your package in the Lucid Developer Dashboard, turn off local development in the Lucid editor where you're working with the extension. Then go through the flow which triggers the data action again. If things are working, it should send you to the OAuth provider at that point. If that works, you should be able to start developing locally again.

Badge +2

Hi @ablackburn 

Thank you for your answer.

Indeed I never been sent through the flow which sends me to the OAuth provider and asks for permission. So you confirm that there is an issue on your side when developping locally ? 

 

Also, I’m not sure to understand the step 2 : I configured an OAuth Provider and I’m able to log the result of this code in my extension : 

 

But I don’t understand when I should be sent through the Oauth Provider flow for the extension permission since my data connector action only perform  console.log() instruction

Userlevel 1
Badge

So you confirm that there is an issue on your side when developping locally ? 

 

Yes, I can confirm this. I have replicated it and am working on a fix. I’ll keep you posted on my progress.

 

But I don’t understand when I should be sent through the Oauth Provider flow for the extension permission since my data connector action only perform  console.log() instruction

 

This is supposed to happen automatically for you between the point where your extension calls `performDataAction`, and when we send the request to your data connector. Basically we take care of making sure the user has authorized your application and getting their authorization tokens stored off, and your data connector gets called once we've got the user's token ready to go. After the user has authorized the extension once, they don't need to go through the flow again since we’ve already got their token,  so we just look it up and forward it to your data connector along with the request from your editor extension.

There is a workaround you can do by going through the authorization flow 1 time without running the extension locally. That should trigger the authorization flow and we will store your token off. After that, you should be able to develop locally again, because the bug appears to be happening specifically when we need to do that authorization step while doing local development.

 

Let me know if you have questions. I’ll follow back up with you when I've got a fix for the bug, but hopefully we can unblock you before then.

 

Alex

Userlevel 1
Badge

Hey Guillaume,

I looked in a bit further and uncovered a simpler workaround. If you have your extension call `editorClient.oauthXhr(...)` before you call `editorClient.performDataAction(...)` then the authorization flow will kick off correctly. Here’s an example:

https://github.com/lucidsoftware/sample-lucid-extensions/pull/21/commits/15896ec4272c0049318edd663cf90d1150d9f0a7#diff-3a5ed2367aa27ba8f9af978e2d2c3465f6089ac6c3c1fba3bbe246e2074bbcc4

 

Let me know if you're still stuck on anything, happy to help out more and/or jump on a call to get things unblocked! I’m working on fixes for the underlying bugs now.

 

Alex

Badge +2

@ablackburn  I’m not sure to understand : you suggest to perform a server call before to trigger the data connector action ? What’s the point ? 

As shared in previous a previous message, my data connector code only returns ‘{success: true} for the moment. I wanted to be sure that everything works.

 

And I can’t see your example with the lnk you provided : 

 

Could you copy/paste a screenshot of an example code please ? 

 

Userlevel 1
Badge

Hi Guillaume, 

Appologies on the link, I didn't realize it would die when I updated the PR. Here's a permanent link to the code I wanted to share:

https://github.com/lucidsoftware/sample-lucid-extensions/blob/main/data-connector-example/editorextensions/data-connector-example/src/extension.ts

 

The important part is here:
 

  // Temporary workaround. You must call oauthXhr once before performDataAction will work
const triggerOauth = await client.oauthXhr("lucid", {
url: "https://api.lucid.co/folders/search",
headers: {
"Lucid-Api-Version": "1",
"Content-Type": "application/json",
},
data: "{}",
method: "POST",
});
const result = await client.performDataAction({
dataConnectorName: "data-connector-1",
actionName: "Import",
actionData: { message: "ImportFolders" },
asynchronous: true,
});

 

The reason is due to a bug on our end that we're ironing out. Basically you must call `client.oauthXhr` once to trigger the authorization flow which fetches + stores the user’s OAuth token for use by the data connector.

 

If you're having trouble still, I wrote up a guide on how to get a minimal data connector working here: https://github.com/lucidsoftware/sample-lucid-extensions/tree/main/data-connector-example

Reply