Skip to content
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

Return an error when direct-nested-loading a subasset #18213

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

andriyDev
Copy link
Contributor

@andriyDev andriyDev commented Mar 9, 2025

Objective

  • Previously, attempting to direct-nested-load a subasset would return the root of the nested-loaded asset. This is most problematic when doing direct-nested-untyped-loads of subassets, where you may not even realize you're dealing with the entirely wrong asset (at least with typed loads, most of the time the root asset has a different type from the subasset, and so at least you'd get an error that the types don't match).

Solution

  • We now return an error when doing these kinds of loads.

Note an alternative would be to "solve" this problem, by just looking up the appropriate subasset after doing the nested load. However there's two problems: 1) we don't know which subassets of the root asset are necessary for the subasset we are looking up (so any handles in that subasset may never get registered), 2) a solution will likely hamper attempts to resolve #18010. AFAICT, no one has complained about this issue, so it doesn't seem critical to fix this for now.

Testing

  • Added a test to ensure this returns an error. I also checked that the other before this was just a mismatched type error, meaning it was trying to pass off the root asset type CoolText as the subasset type SubText (which would have worked had I not been using typed loads).

@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Mar 9, 2025
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Assets Load files from disk to use for things like images, models, and sounds labels Mar 9, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I really like pushing asset loading towards clear, error-returning behavior. It's way too hard to reason about anything else IMO.

@andriyDev andriyDev force-pushed the error-on-nested-load-subasset branch from a1968f0 to f0d4968 Compare March 9, 2025 21:52
@andriyDev
Copy link
Contributor Author

(forgot to rebase before pushing, sorry)

@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need some way to nest labeled assets
2 participants