-
Notifications
You must be signed in to change notification settings - Fork 1
Added a fallback case for pointers without ["uuid"] #20
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
base: main
Are you sure you want to change the base?
Conversation
|
Hm, this is weird, then another problem probably must have occurred when preprocessing the node trees. Before exporting, all node trees should receive a uuid if they don't yet have one |
There was a problem hiding this 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 KeyError issue in the _get_pointer function when elements don't have a "uuid" key. The function was previously using direct dictionary access which caused exceptions in Blender 4.5 with certain Geometry node groups.
Key changes:
- Replaced direct dictionary access with try-catch fallback logic
- Added proper error handling for both
.get()method and dictionary access patterns
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| try: | ||
| return element.get("uuid") | ||
| except AttributeError: | ||
| try: | ||
| return element["uuid"] | ||
| except (KeyError, TypeError): | ||
| return None | ||
|
|
||
|
|
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic flow is unnecessarily complex. Consider checking if the element has dictionary-like behavior first, then use .get() with a default value. This would be more readable: return getattr(element, 'get', lambda k, default=None: element.get(k, default) if hasattr(element, 'get') else element.get(k) if k in element else default)('uuid') or simply use a more straightforward approach with hasattr checks.
| try: | |
| return element.get("uuid") | |
| except AttributeError: | |
| try: | |
| return element["uuid"] | |
| except (KeyError, TypeError): | |
| return None | |
| if hasattr(element, "get"): | |
| return element.get("uuid", None) | |
| elif isinstance(element, dict) and "uuid" in element: | |
| return element["uuid"] | |
| elif hasattr(element, "__getitem__") and "uuid" in element: | |
| try: | |
| return element["uuid"] | |
| except Exception: | |
| return None | |
| return None |
| return None | ||
|
|
||
| try: | ||
| return element.get("uuid") |
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using element.get("uuid") without a default value returns None when the key doesn't exist, but this could mask the case where the uuid value itself is intentionally None. Consider using element.get("uuid", None) explicitly or handle the distinction between missing keys and None values.
| return element.get("uuid") | |
| return element.get("uuid", None) |
In Blender 4.5 with a particular Geometry node group, I was running into issues in attributes.py:41
The fix is to also check for element.get("uuid") which fixes the the issue.
Orginal:
Fix: