Skip to content

Fix parsing OSD to InventoryItem - #2

Merged
mercurylinden merged 1 commit into
masterfrom
mercury/fix_osd_inv_parsing
Jul 30, 2026
Merged

Fix parsing OSD to InventoryItem#2
mercurylinden merged 1 commit into
masterfrom
mercury/fix_osd_inv_parsing

Conversation

@mercurylinden

Copy link
Copy Markdown

the inv_type, type, and owner_id fields were not getting parsed correctly into the InventoryItem type based on how the OSD from a RequestTaskInventory request is structured.

Copilot AI left a comment

Copy link
Copy Markdown

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 InventoryItem.FromOSD(...) to correctly parse task-inventory (RequestTaskInventory) LLSD/OSD payloads where inv_type and type can be strings, and where owner_id lives under the permissions map.

Changes:

  • Parse inv_type and type as either string (via Utils.StringTo*Type) or integer.
  • Fix OwnerID parsing to read from permissions.owner_id (instead of agent_id).
  • Preserve the attachment-type correction logic, now based on the parsed invType/assetType.
Comments suppressed due to low confidence (1)

LibreMetaverse/Inventory/InventoryBase.cs:302

  • type parsing has the same issue as inv_type: anything that isn't an OSDType.String is treated as an integer. If the value is missing/undefined or comes in as another type, this can silently map to 0 instead of leaving the type unknown. Consider using the same String/Integer-only switch approach used by Update().
            AssetType assetType = descItem["type"].Type == OSDType.String
                ? Utils.StringToAssetType(descItem["type"].AsString())
                : (AssetType)descItem["type"].AsInteger();

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

Comment on lines +296 to +298
InventoryType invType = descItem["inv_type"].Type == OSDType.String
? Utils.StringToInventoryType(descItem["inv_type"].AsString())
: (InventoryType)descItem["inv_type"].AsInteger();
Comment on lines 328 to 332
OSDMap perms = (OSDMap)descItem["permissions"];
item.OwnerID = perms["owner_id"];
item.CreatorID = perms["creator_id"];
item.LastOwnerID = perms["last_owner_id"];
item.Permissions = new Permissions(perms["base_mask"], perms["everyone_mask"], perms["group_mask"], perms["next_owner_mask"], perms["owner_mask"]);
@mercurylinden
mercurylinden merged commit a5eb366 into master Jul 30, 2026
1 check passed
@mercurylinden
mercurylinden deleted the mercury/fix_osd_inv_parsing branch July 30, 2026 22:13
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