Skip to content

Conversation

Copy link

Copilot AI commented Jan 30, 2026

The find_all_contacts() function crashes with ValueError: not enough values to unpack when any contact name contains fewer than 2 spaces. This breaks the entire contact extraction feature.

# Crashes on common names
name, note, label = "王五".rsplit(" ", maxsplit=2)  # ValueError
name, note, label = "李四 备注".rsplit(" ", maxsplit=2)  # ValueError

Changes

  • Error handling: Wrap rsplit() in try-except at lines 218 and 243
  • Fallback logic: Parse names with 0-2 spaces gracefully, setting missing fields to empty strings
  • Applied to both locations: Initial contact load and scroll pagination loop
try:
    name, note, label = contact.Name.rsplit(" ", maxsplit=2)
except ValueError:
    parts = contact.Name.rsplit(" ", maxsplit=1) if " " in contact.Name else [contact.Name]
    if len(parts) == 2:
        name, note = parts
        label = ""
    else:
        name = parts[0]
        note = ""
        label = ""

Maintains backward compatibility with existing 3-part contact names while handling 1-2 part names without crashing.

Original prompt

Scan the repository for the most critical bug, then implement a targeted fix and explain your approach.

Custom agent used: bug-fix-teammate
Identifies critical bugs in your project and implements targeted fixes with working code


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 30, 2026 08:35
…ct names

Co-authored-by: LTEnjoy <52776915+LTEnjoy@users.noreply.github.com>
Co-authored-by: LTEnjoy <52776915+LTEnjoy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix most critical bug in repository Fix ValueError crash in contact extraction when names have fewer than 2 spaces Jan 30, 2026
Copilot AI requested a review from LTEnjoy January 30, 2026 08:38
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