Magento2 Invalid return error when uploading VCL snippets to Fastly
I'm trying to create a 301 redirect that is very similar to this one:
https://support.fastly.com/hc/en-us/community/posts/360040168631-How-Does-vcl-error-Work-
In my case, I simply want to redirect any request for www.shop.example.com to shop.example.com (The real domain I'm working with has been replaced by "example", for privacy fyi)
I have a VCL snippet for RECV:
if (req.http.host == "www.shop.example.com") {
error 619 "Redirect www.shop";
}
Then I have a VCL snippet for ERROR:
if (obj.status == 619 && obj.response == "Redirect www.shop") {
set obj.status = 301;
set obj.response = "Moved Permanently";
set obj.http.Location = "https://shop.example.com" req.url;
synthetic {""};
return (deliver);
}
When I try to upload my VCL from Magento to Fastly:
Invalid return `error` ...in function `vcl_error` ...which is the `vcl_error` method Legal returns are: `deliver` `deliver_stale` `restart` at: (input Line 12079 Pos 5) error 619 "Redirect www.shop";
This is a pretty basic use case for Fastly, and after much Googling, I can't find anything helpful. Does anyone here have any idea why this error is being thrown?
-
Hi Chris! I don't see anything wrong with the VCL snippets, but from past tickets we've seen this error reported when the wrong subroutine is chosen -- ie. vcl_error instead of vcl_recv.
Could you please check to see that the VCL snippets are in the correct subroutines?
Also, I'm happy to take a deeper look into your configuration to see if there are any other factors contributing to the error you see. Let me know if that's something you require, and I can open a ticket from this post. Also feel free to open a ticket with support@fastly.com any time.
-
Hey Trin - thanks for the quick response. Currently, here are some screen shots of the types. They are correctly assigned to recv and error types. I have many other snippets too. I had the following thought, however this seems very unlikely to me, but is it possible that I'm not allowed to call error from multiple recv snippets? I have one other recv snippet that is doing some geoip redirecting for continental Europe that has no issues whatsoever when saving.
-
Thanks for checking! I think this requires a deeper look into your configuration, so I've created a ticket from this post. Please check your inbox for an email from support@fastly.com. Once resolved we can post the solution here for visibility.
Please sign in to leave a comment.
Comments
4 comments