Skip to content

fix: support biz_message_N.db filename pattern in export_messages.py#7

Open
Techeek wants to merge 1 commit intoThearas:mainfrom
Techeek:fix/biz-message-db-detection
Open

fix: support biz_message_N.db filename pattern in export_messages.py#7
Techeek wants to merge 1 commit intoThearas:mainfrom
Techeek:fix/biz-message-db-detection

Conversation

@Techeek
Copy link

@Techeek Techeek commented Mar 12, 2026

Problem

export_messages.py failed with '[-] No message databases found in decrypted/message/' because get_all_msg_dbs() only matched message_N.db filenames, but newer versions of WeChat for macOS name the databases biz_message_N.db instead.

Fix

Updated the regex in get_all_msg_dbs() from ^message_\d+.db$ to ^(biz_)?message_\d+.db$ to match both message_0.db and biz_message_0.db patterns.

Copilot AI review requested due to automatic review settings March 12, 2026 03:44
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue in the export_messages.py script where it failed to locate message databases due to an outdated filename pattern. The change updates the regular expression used to identify these database files, ensuring compatibility with newer WeChat for macOS versions that use a biz_message_N.db naming convention. This fix enhances the script's robustness and broadens its applicability.

Highlights

  • Database Filename Pattern Support: The export_messages.py script has been updated to correctly identify message database files that follow the biz_message_N.db naming convention, in addition to the existing message_N.db pattern. This resolves an issue where newer WeChat for macOS versions were not being recognized.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • export_messages.py
    • Updated the regular expression in the get_all_msg_dbs function to match biz_message_N.db filenames, alongside the original message_N.db pattern.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly extends the get_all_msg_dbs function to support the biz_message_N.db filename pattern, in addition to the existing message_N.db pattern. The change is simple and effective. I've added one suggestion to refactor the function for better readability and to remove a redundant import, following Python best practices.

Comment on lines 102 to 110
import re
msg_dir = os.path.join(decrypted_dir, "message")
if not os.path.isdir(msg_dir):
return []
dbs = []
for f in sorted(os.listdir(msg_dir)):
if re.match(r"^message_\d+\.db$", f):
if re.match(r"^(biz_)?message_\d+\.db$", f):
dbs.append(os.path.join(msg_dir, f))
return dbs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function can be refactored for better readability and to follow Python best practices:

  • The import re statement is redundant because re is already imported at the top of the file. Per PEP 8, imports should be at the module level.
  • The loop that builds the dbs list can be replaced with a more concise list comprehension.

Here's a suggested implementation that applies these improvements.

Suggested change
import re
msg_dir = os.path.join(decrypted_dir, "message")
if not os.path.isdir(msg_dir):
return []
dbs = []
for f in sorted(os.listdir(msg_dir)):
if re.match(r"^message_\d+\.db$", f):
if re.match(r"^(biz_)?message_\d+\.db$", f):
dbs.append(os.path.join(msg_dir, f))
return dbs
msg_dir = os.path.join(decrypted_dir, "message")
if not os.path.isdir(msg_dir):
return []
dbs = [
os.path.join(msg_dir, f)
for f in sorted(os.listdir(msg_dir))
if re.match(r"^(biz_)?message_\d+\.db$", f)
]
return dbs
References
  1. PEP 8 style guide suggests that imports should be placed at the top of the module, not inside functions, to improve clarity and avoid issues with module loading. (link)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates message database discovery to support newer WeChat for macOS naming, so exports work when decrypted DBs are named with the biz_ prefix.

Changes:

  • Expand get_all_msg_dbs() filename matching to include biz_message_N.db.
  • Update the function docstring to reflect the supported filename patterns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 106 to 109
dbs = []
for f in sorted(os.listdir(msg_dir)):
if re.match(r"^message_\d+\.db$", f):
if re.match(r"^(biz_)?message_\d+\.db$", f):
dbs.append(os.path.join(msg_dir, f))
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message DB filename matching logic is duplicated elsewhere (e.g., mcp_server.py:get_msg_dbs still only matches ^message\d+.db$). This change fixes export_messages.py but leaves other entry points potentially broken on newer WeChat macOS versions; consider updating the other helper(s) as well or centralizing the pattern to avoid future divergence.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants