(Can’t attach evidence here; it contains a proprietary API key. Please contact me via email.)
I’m building an agent for a client, and the following error occurs randomly on every run:
I created a simple Python script to count the characters from the text string returned by Scrape URL. Works about 98% of the time, but the other 2% throws this error:
**7 Executing "ScrapeSize"**
**8 Error: SyntaxError: Unexpected token '<', "<html>**
**<h"... is not valid JSON
**
The function does nothing but count characters and return a numeric value. So I don’t understand where that’s coming from. The output from Scrape URL and input to the function is just plain text, which can be seen in the debugger log.
I can do an imprecise work-around with a Generate Text block, but it would be better (and cheaper) if the Python function was 100% reliable.
Any guidance you can offer would be gratefully appreciated!
It seems this could be happening when a Scrape URL block saves an HTML error or redirect page to a variable, so the function receives HTML instead of JSON.
Could you send me a direct message with the Debugger logs for that run? To do that, open the Debugger, select the run, click Share, and reply with the URL: