Fix parsing OSD to InventoryItem - #2
Merged
Merged
Conversation
There was a problem hiding this comment.
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_typeandtypeas either string (viaUtils.StringTo*Type) or integer. - Fix
OwnerIDparsing to read frompermissions.owner_id(instead ofagent_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
typeparsing has the same issue asinv_type: anything that isn't anOSDType.Stringis treated as an integer. If the value is missing/undefined or comes in as another type, this can silently map to0instead of leaving the type unknown. Consider using the same String/Integer-only switch approach used byUpdate().
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"]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
the
inv_type,type, andowner_idfields were not getting parsed correctly into theInventoryItemtype based on how the OSD from aRequestTaskInventoryrequest is structured.