Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential GMail bug causes exporting to XML not working with category action rules, workaround needed #363

Closed
chaserhkj opened this issue Oct 25, 2023 · 2 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity, has become stale and will be auto-closed. question Further information is requested

Comments

@chaserhkj
Copy link

chaserhkj commented Oct 25, 2023

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?

@mbrt
Copy link
Owner

mbrt commented Oct 30, 2023

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)

@mbrt mbrt added the question Further information is requested label Oct 30, 2023
Copy link
Contributor

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.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity, has become stale and will be auto-closed. label Nov 30, 2023
@github-actions github-actions bot closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity, has become stale and will be auto-closed. question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants