Potential GMail bug causes exporting to XML not working with category action rules, workaround needed
Closed this issue · 2 comments
I wanted to use gmailctl
to apply my filter rules to my existing mail archives as well, so I followed the recommended way of exporting from gmailctl
to XML and then importing it from GMail UI with the "Apply new filters to existing email" option. However, it turns out that any rules with {action: {category: "some_category"}}
will fail to import in this way. The import will report a failure and the imported filter will just miss the category action.
After some trials and tweaks, I am confident this could be a potential Gmail bug. I tried creating a filter in Gmail using the categorize action and then exporting and re-importing it. It will fail in the very same way.
Currently, as a workaround, I am maintaining a separate configuration without all the category actions just for exporting the XML. Maybe this could be made a flag into gmailctl export
that just automatically turns off all category actions?
I don't think gmailctl is the right place to workaround (hopefully temporary) issues in Gmail. Was this reported to Google?
In the meantime you could have a simple python script to filter the output for you?
Directly taken from ChatGPT (I haven't tested it):
import xml.etree.ElementTree as ET
# Load your XML document
xml_string = """
<root>
<entry>
<tag>keep</tag>
<other>data</other>
</entry>
<entry>
<tag>remove</tag>
<other>data</other>
</entry>
<entry>
<tag>keep</tag>
<other>data</other>
</entry>
</root>
"""
# Parse the XML string into an ElementTree
root = ET.fromstring(xml_string)
# Specify the tag to remove
tag_to_remove = "remove"
# Find and remove elements with the specified tag
for entry in root.findall('.//entry'):
tag_element = entry.find('./tag')
if tag_element is not None and tag_element.text == tag_to_remove:
root.remove(entry)
# Convert the modified XML tree back to a string
filtered_xml = ET.tostring(root).decode()
# Print the filtered XML
print(filtered_xml)
This issue is stale because it has been open for 30 days without activity.
This will be closed in 7 days, unless you add the 'lifecycle/keep-alive' label or comment.