My app is working for SEO. I was trying to update article title and body_html with Python API. It was successful but the article featured image was gone. The featured image can't be found in the blog post. My code didn't change featured image at all.
Why is it happening? How can I fix it?
Hey there,
This sounds strange, I haven't been able to replicate on my own test store.
Do you happen to have an example request ID where this happened, or even the ID of the article that you were updating and a rough timeframe in which the update would have occurred? I could check our logs here to see if anything looks out of place.
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Article I'd should be 29590913101. The title is "WAS HAT TAPKEY MIT COWORKING ZU TUN?"
I used this line target = shopify.Article.find(target_id, blog_id = blog_id) to find out the blog article. I tried to update title and description with
target.title = title
target.body_html = description
However, after I called target.save(), the feature image was removed. the image attribute of the article was gone.
Can you help me have a check? Thanks in advance
Hey again,
It looks like that article has had several updates performed on it, and I've been trying to copy them but still haven't been able to get the image to remove itself while making calls with an HTTP client.
Is there any chance you track request IDs and know of a specific request that caused the image to be deleted, or should I assuming that all of these updates caused the image issue to occur?
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Yes, I've added some codes to check which part caused the crash.
shopify.ShopifyResource.activate_session(session)
result = checkAjaxPOST(request)
if result != 1:
return result
type_value = request.POST.get('type')
target_id = request.POST.get('id')
target = ''
if type_value == 'product':
target = shopify.Product.find(target_id)
elif type_value == 'article':
blog_id = request.POST.get('blog_id')
target = shopify.Article.find(target_id, blog_id = blog_id)
# logger.info("article = " + target.title + " handle = " + target.handle)
print "article = " + target.title + "; handle = " + target.handle
if hasattr(target, 'image'):
print "; image 0 = " + target.image.src
else:
print "image 0 = none"
# target.image = target.image # image is lost after setting the focus keyword. This line is to fix this bug
else:
return JsonResponse({ 'error': 'not valid type_value.' })
title = request.POST.get('title')
keywords = request.POST.get('keywords')
description = request.POST.get('description')
target.title = title
target.body_html = description
target.save()
target = shopify.Article.find(target_id, blog_id = blog_id)
if hasattr(target, 'image'):
print "; image 1 = " + target.image.src
else:
print "image 1 = none"
loop_var = { 0 : {'key': 'keywords_tag', 'value': keywords} }
for index in loop_var:
updateMetafield(index, loop_var, target_id, type_value)
target = shopify.Article.find(target_id, blog_id = blog_id)
if hasattr(target, 'image'):
print "; image 2 = " + target.image.src
else:
print "image 2 = none"
data = {"title": title, "keywords": keywords, "description": description}
return JsonResponse(data)
After testing, I got
article = WAS HAT TAPKEY MIT COWORKING ZU TUN?; handle = was-hat-tapkey-mit-coworking-zu-tun
[Thu Oct 25 17:04:59.128389 2018] [:error] [pid 23977] ; image 0 = https://cdn.shopify.com/s/files/1/1498/3202/articles/23102018_Challenges_Coworking_900x_18bbcf15-1be...
[Thu Oct 25 17:05:01.776095 2018] [:error] [pid 23977] image 1 = none
[Thu Oct 25 17:05:05.006657 2018] [:error] [pid 23977] image 2 = none
When I tried to move target.save() at the end before return, I got:
article = WAS HAT TAPKEY MIT COWORKING ZU TUN?; handle = was-hat-tapkey-mit-coworking-zu-tun
[Thu Oct 25 17:17:45.951124 2018] [:error] [pid 24141] ; image 0 = https://cdn.shopify.com/s/files/1/1498/3202/articles/pexels-photo-884977.jpeg?v=1540459039
[Thu Oct 25 17:17:47.014086 2018] [:error] [pid 24141] ; image 1 = https://cdn.shopify.com/s/files/1/1498/3202/articles/pexels-photo-884977.jpeg?v=1540459039
[Thu Oct 25 17:17:50.308937 2018] [:error] [pid 24141] ; image 2 = https://cdn.shopify.com/s/files/1/1498/3202/articles/pexels-photo-884977.jpeg?v=1540459039
So I don't know why it's going wrong.
Hey Josh, can you check anything in your side?
Hello again,
I'm still working on attempting to replicate this but have not been able to. When checking our logs as well, any logs of attempts by your app to update the blog article have now expired so I wouldn't be able to copy them.
Would you be able to update the article with another featured image, and then perform the same update that caused the image to be removed? It would be ideal if you could only perform a single update as well to make it easier to track down where the issue may lie - or provide the value of the X-Request-Id header from the response you receive after performing the update.
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi,
I tried to duplicate the issue with 4 - 5 requests for this article: https://sillycube-test.myshopify.com/blogs/news/was-hat-tapkey-mit-coworking-zu-tun. The last request can duplicate the issue.
When I tried to update the keywords metafield from "coworking" to "coworking1", the featured image was cleared. I was testing the issue in spo_development app: https://partners.shopify.com/491836/apps/1501395#/
Hey again,
Updating a metafield shouldn't ever remove a featured image either. If your last article update can replicate the issue that you've been seeing though, your last update also contained an image URL that doesn't exist - so it likely would have given the appearance of an image disappearing because our attempt to download the image returned a 404 error.
I would suggest double-checking any image URLs that you're using, and then try an update again.
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Thanks.
I tried to investigate where I updated the image url but didn't see it. The above code should be showing the same as my code.
So I tried to duplicate the issue again. When I uploaded this image (the file name is called "LAUNCHING A STARTUP IN 24 HOURS.png". I tried with another file with no space. Still the same), the file url is https://cdn.shopify.com/s/files/1/1498/3202/articles/LAUNCHING_A_STARTUP_IN_24_HOURS_grande.png?v=15...
Again I changed the metafield to reproduce this issue. The feature image file url still exists. However, I can't find the feature image in the blog article section: https://sillycube-test.myshopify.com/admin/blogs/80952777/articles/29590913101
I don't think I've changed the feature image in the above code.
Also, the error is coming out at a random interval when updating the metafield (called focus keyword in my app). Sometimes it occurs. Sometimes it doesn't.
I tried to follow this post to print the error when saving article: https://groups.google.com/forum/#!topic/shopify-app-discuss/U07XoBgN7eU
I got the following errors:
[Thu Jan 17 16:02:33.846923 2019] [:error] [pid 12042] True
[Thu Jan 17 16:02:33.847030 2019] [:error] [pid 12042] []
[Thu Jan 17 16:03:03.527992 2019] [:error] [pid 12042] True
[Thu Jan 17 16:03:03.528074 2019] [:error] [pid 12042] []
[Thu Jan 17 16:03:21.918293 2019] [:error] [pid 12042] True
[Thu Jan 17 16:03:21.918377 2019] [:error] [pid 12042] []
[Thu Jan 17 16:03:37.799649 2019] [:error] [pid 12042] False
[Thu Jan 17 16:03:37.799738 2019] [:error] [pid 12042] [u'Image upload failed. Image https://cdn.shopify.com/s/files/1/1498/3202/articles/SILLYCUBE_logo_deliver_slogan_1200w_630h_32df9b... failed to download. - file not found. Check that file can be found at your URL.']
[Thu Jan 17 16:05:50.522924 2019] [:error] [pid 12042] article(29590913101)
[Thu Jan 17 16:06:06.684337 2019] [:error] [pid 12042] True
[Thu Jan 17 16:06:06.684402 2019] [:error] [pid 12042] []
[Thu Jan 17 16:06:23.289359 2019] [:error] [pid 12042] False
[Thu Jan 17 16:06:23.289988 2019] [:error] [pid 12042] [u'Image upload failed. Image https://cdn.shopify.com/s/files/1/1498/3202/articles/test-fb1.png?v=1547712366 failed to download. - file not found. Check that file can be found at your URL.']
Why sometimes it can upload the image and sometimes it can't? The code is the same. How can I resolve the problem?
I have the same issues when I update article. Here is my code:
shopifyArticle = ShopifyAPI::Article.find(gId) if shopifyArticle.published_at == nil
shopifyArticle.published_at = Time.current end shopifyArticle.save
Image upload failed. Image https://cdn.shopify.com/s/files/1/0076/2701/4233/articles/yuanpei-hua-1386443-unsplash.jpg?v=1556769360 failed to download. - file not found. Check that file can be found at your URL.Why sometimes it can upload but sometimes it cannot?
User | RANK |
---|---|
7 | |
5 | |
4 | |
4 | |
3 |