@sudsy @dorilama please check out the video of what I am experiencing. It doesn’t seem to be anything related to the plugin builder being finicky or quirky.
I’ve tried to add extra spaces, remove all spaces between the first curly brace and it doesn’t change things. I’ve also ensured it is wrapped by function (properties, context){ }
In the video you will notice the return values section is completely absent, and I’m not sure if that has anything to do with it.
But in my testing before reporting the bug, I copied code from other plugins of mine that don’t have the error, and pasted into a new plugin or the plugin which the bug first was spotted and the error shows for those. Not sure why the same code works and has no error in one plugin but in another it would. I also copied working code from other actions of the same plugin and the same thing, code without the error from another action will produce the error when pasted into a new action in the same plugin.
This is the code I tested with in the video…please let me know if this code has wrong formatting or is an issue in how it is wrapped.
async function (properties, context) {
try {
const primaryColor = properties.primary_color;
if (!/^#[0-9A-F]{6}$/i.test(primaryColor)) {
throw new Error("Invalid primary color. It must be a hex color code (e.g., #6200EE).");
}
// Helper function to convert HEX to RGB
function hexToRgb(hex) {
const bigint = parseInt(hex.slice(1), 16);
return [(bigint >> 16) & 255, (bigint >> 8) & 255, bigint & 255];
}
// Convert primary color to RGB
const primaryColorRgb = hexToRgb(primaryColor);
// Format the RGB value as a string
const primaryColorRgbString = `rgb(${primaryColorRgb.join(",")})`;
// Return the result
return {
primary_color: primaryColorRgbString
};
} catch (error) {
console.error("Error in plugin action:", error);
return {
primary_color: "Invalid color"
};
}
}
Trying to debug with ChatGPT using simple questions derived from the error message.
Does this script have more than 2,000,000 characters?
No, the script provided does not have more than 2,000,000 characters. It is relatively small and concise, consisting of only a few hundred characters at most. It is well within the character limit set by the error. You should be able to save and use this script without any issues related to character count.
Is this script wrapped by function (properties, context){ }
Yes, the script is correctly wrapped by async function (properties, context) { }
. This ensures that it adheres to the required structure for a plugin action or function in systems that use this format, such as plugin development in certain platforms.
Can the script be interpreted as javascript?
Yes, the script can be interpreted as JavaScript. Here’s why:
- Proper Syntax: The script uses valid JavaScript syntax, including proper use of functions, variable declarations, error handling, and return statements.
- Wrapped in a Function: The script is correctly wrapped with
async function (properties, context) { }
, which is a valid JavaScript function definition.
- No Extraneous Characters: The script contains no extraneous characters or malformed syntax that would prevent it from being parsed as JavaScript.
- Complies with JavaScript Standards: The code adheres to modern JavaScript ES6+ standards, including the use of
async/await
, template literals, and modern function definitions.
If there is an issue with interpretation, it would likely not be due to the syntax or JavaScript validity but possibly due to platform-specific constraints or errors elsewhere in the implementation.
I’m pretty much at a loss of explanation except that there is a bug.
Is anybody else experiencing this bug with the plugin editor?