Skip to content

[WIP] Coercing to Unicode #166

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

[WIP] Coercing to Unicode #166

wants to merge 3 commits into from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 27, 2025

  • Understand the issue with numeric string dict keys
  • Reproduce the issue with a test case
  • Compare the handling in _item_added vs _item_removed
  • Fix the _item_added method to use similar type checking as _item_removed
  • Verify the fix with tests
  • Document the changes

The issue occurs when handling dictionary keys that are numeric strings (like '1'). The key property in the PatchOperation class tries to convert these to integers, which confuses the logic in _item_added when determining if it should update array indices.

The problem is that the original code checks if type(op.key) == int and type(key) == int: to determine if it's handling arrays, but this can incorrectly match dictionary keys that are numeric strings because they get converted to integers.

This patch makes the _item_added method more robust by checking the actual data structure type (like what's already done in _item_removed) instead of relying on key type checking. This ensures that numeric string dictionary keys (like '1') are treated correctly as dictionary keys rather than array indices, preventing the "coercing to Unicode" error.

Fixes #97.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits May 27, 2025 21:21
Co-authored-by: stefankoegl <184196+stefankoegl@users.noreply.github.com>
Co-authored-by: stefankoegl <184196+stefankoegl@users.noreply.github.com>
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.

Coercing to Unicode
2 participants