Updating product via admin console API breaks before:product.updated in certain conditions #642
|
Updating a product via Reproduction steps:
export const config: SwellConfig = {
description: 'Auto-calculate product price from width/height attributes',
model: {
events: ['before:product.created', 'before:product.updated'],
sequence: 1,
},
};
const round2 = (n: number): number => Math.round(n * 100) / 100;
export default async function (req: SwellRequest) {
const { data } = req;
const width = parseFloat(data.attributes?.width);
const height = parseFloat(data.attributes?.height);
if (isNaN(width) || isNaN(height)) {
console.log('No valid width/height attributes, skipping price calculation');
return;
}
const eurPrice = round2(width * height * 0.1);
const usdPrice = round2(width * height * 0.12);
console.log(`Calculating price: EUR ${eurPrice}, USD ${usdPrice}`);
return {
price: eurPrice,
currency: 'EUR',
purchase_options: {
standard: {
active: true,
price: eurPrice,
$currency: {
EUR: { price: eurPrice },
USD: { price: usdPrice },
},
},
},
$currency: {
EUR: { price: eurPrice },
USD: { price: usdPrice },
},
};
}
// PUT
{ "name": "Misty Mountains at Dawn" }
//PUT
{ "meta_title": "Misty Mountains at Dawn – BitBlocks Mosaic Wall Art" }
|
Answered by
dminch
Apr 1, 2026
Replies: 1 comment
|
Thanks again for the clear reproduction, this nailed it for us. We were passing product data through an internal HTTP header that doesn't support special characters. The dash in your meta_title is what triggers it. The reason the product appears permanently broken: once that character is stored on the product, the full record gets included in every subsequent function invocation, so it keeps failing. Removing the en dash from meta_title should restore function execution for that product. The fix is in place. Pls, update cli and try it. |
0 replies
Answer selected by
sebastian-meckovski
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks again for the clear reproduction, this nailed it for us. We were passing product data through an internal HTTP header that doesn't support special characters. The dash in your meta_title is what triggers it.
The reason the product appears permanently broken: once that character is stored on the product, the full record gets included in every subsequent function invocation, so it keeps failing. Removing the en dash from meta_title should restore function execution for that product.
The fix is in place. Pls, update cli and try it.