Some actions JS blocks cannot be parsed as JS code

Hi,

I am trying to publish my plugin but this piece of code is causing Bubble to throw the error “Action plugin: Some actions JS blocks cannot be parsed as JS code. Please check.”.

The piece of code works perfectly fine in my test app, but Bubble just won’t let me publish it. There are no errors in the console or in the code editor for action. It’s running as a server-side action.

If anyone has a minute can you please review the code and suggest any reasons why Bubble may not be able to publish it? :crossed_fingers:

Thank you all!!!

function(properties, context) {
    
 
const response = context.request({
    
method: "post",
    
uri: "https://paper.xyz/api/v1/checkout",
    
headers: {"Accept": "application/json",
                 "Authorization": "Bearer <MYAPIKEY>",
                 "Content-Type": "application/json"},
    
 body:{ "contractChain": properties.contract_chain,
       "contractType": "THIRDWEB_NFT_DROP_V2",  
       "requireVerifiedEmail": false,
       "hideNativeMint": false,
       "hidePayWithCard": false,
       "hidePayWithCrypto": false,
       "hideConnectPaperWallet": false,
       "hideConnectExternalWallet": false,
       "brandDarkMode": false,
       "brandButtoneShape": "lg",
       "brandColorScheme": properties.color_scheme,
       "hasPublicLink": true,
       "limitPerTransaction": properties.limit_per_transaction,
       "redirectAfterPayment": false,
       "shouldSendTransferCompletedEmail": true,
       "successCallbackUrl": properties.success_url,
       "contractAddress": properties.contract_address,
       "collectionDescription": properties.collection_description,
       "collectionTitle": properties.collection_name,
       "cancelCallbackUrl": properties.cancel_url,
       "imageUrl": properties.image_url,
       "sellerTwitterHandle": properties.seller_twitter_handle},
    
json: true});   
    
   
return {checkouturl: JSON.stringify(response.body.checkoutUrl).replace('"','').replace('"','')};   

}

Assuming you’re creating a server side action?

I think I had a similar issue when I accidentally left some bad code in the client side code section.

Alternatively, run your code through a javascript parser or use VS Code

2 Likes

What I do when this happens is;

  • copy the method code into a text editor eg Sublime to get rid of any wonky chars
  • delete the action and create from scratch a new plug-in method (paste in the code from step 1) to get rid of any orphan references from the screwed up plug-in method.

Good luck :slightly_smiling_face:

3 Likes

That was the problem! Thank you!

Thank you for your response!

I’m having the same issue, but there is literally nothing wrong with the plugin’s code. I have parsed the code in the browser, and also using nodejs, no syntax errors. In addition, all the plugin’s actions are working flawlessly when called from within my bubble application. And yet, I cannot publish the plugin and am limited to using it on test mode.

While I was investigating the problem, I also tried creating a new plugin and adding each action one by one, while publishing to see if I could identify which (if any) of them was causing the problem. I could not publish, even with only one server side action, with ZERO syntax errors. And before you say it’s my fault, this is not my first rodeo… I’m a senior developer by craft, and I would 100% know if there was a syntax error on the code.

Adding insult to injury, I’ve just tried to publish a private plugin with a mostly empty server side action, no syntax errors, and got the same error. I can say with confidence now that this is not a problem on the developer’s side.

Check in the client-side code section, you may have some code in there still that shouldn’t be there. That was the issue for me!

Screen Shot 2024-02-07 at 6.48.56 AM

4 Likes

I ran into this exact same error too

I just heard back from Bubble support, to fix this, you need to reset the client side code to this:

function(properties, context) {

//Load any data

//Do the operation

}

1 Like

Spent a few hours looking for the problem here

Isolated it down to a single action, JS was grand

Though this was my issue - hidden from sight!

Just replaced everything Client side with
"
function(properties, context) {

//Load any data

//Do the operation

}
"

Man I love U, that was my case

Thanks! :heart: :colombia:

Thanks a lot for saving the world :raised_hands:

Thanks all! That was it.