Skip to content

Conversation

@MrPoopey
Copy link

The _lowercase_keys helper function previously lowercases all string keys which unintentionally breaks OData keys such as @odata.bind. These keys are case sensitive and must remain unchanged for Dataverse to interpret them correctly.

Copilot AI review requested due to automatic review settings January 16, 2026 04:31
@MrPoopey MrPoopey requested a review from a team as a code owner January 16, 2026 04:31
@MrPoopey
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

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

This PR fixes a bug where OData annotation keys were being incorrectly lowercased. The _lowercase_keys helper function now preserves case-sensitive OData keys (like @odata.bind) while still normalizing Dataverse attribute names to lowercase.

Changes:

  • Modified _lowercase_keys to detect and preserve OData annotation keys by checking for "@OData" substring
  • Updated docstrings and inline comments to reflect the new behavior

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

Comment on lines 94 to 113
def _lowercase_keys(record: Dict[str, Any]) -> Dict[str, Any]:
"""Convert all dictionary keys to lowercase for case-insensitive column names.
"""Normalize dictionary keys to lowercase for case-insensitive column names.

Dataverse LogicalNames for attributes are stored lowercase, but users may
provide PascalCase names (matching SchemaName). This normalizes the input.
This function lowercases all string keys except OData annotation keys,
which must remain case-sensitive.
"""
if not isinstance(record, dict):
return record
return {k.lower() if isinstance(k, str) else k: v for k, v in record.items()}

new_record = {}

# Preserve OData annotation keys as they are case sensitive
for k, v in record.items():
if isinstance(k, str) and "@odata" in k:
new_record[k] = v
else:
new_record[k.lower() if isinstance(k, str) else k] = v
return new_record
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The _lowercase_keys function lacks test coverage for the new behavior of preserving OData annotation keys. Consider adding tests that verify OData keys like "@odata.bind", "@odata.type", and "@odata.nextLink" are preserved with their original casing while regular attribute keys are lowercased.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@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.

1 participant