Stop FileAccess::fix_path
from emitting errors for invalid UIDs
#107402
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.
Fixes #101962.
This is mostly a quick hack to prompt a discussion about a more proper fix, and maybe serve as a hold-over, but...
This adds a
ResourceUID::has_id
check toFileAccess::fix_path
, before it tries to callResourceUID::text_to_id
, and instead just clears the output string if it's not a known UID, same as what this error check is already doing inadvertently by returning an emptyString
when it can't find the UID:godot/core/io/resource_uid.cpp
Line 199 in 51b0379
Without this, you could otherwise pass perfectly reasonable (or not) but non-existent
uid://
paths toFileAccess::fix_path
and it would emit the above mentioned error aboutUnrecognized UID
, which is exactly what happens in places like the LSP server, where it runs every string literal in the GDScript file throughFileAccess::file_exists
, which in turn callsFileAccess::fix_path
, as seen here:godot/modules/gdscript/language_server/gdscript_extend_parser.cpp
Lines 207 to 214 in 51b0379
I feel like the proper fix is to change
FileAccess::fix_path
to instead return abool
, to indicate a failure to fix/resolve the path, like when trying to fix/resolve a non-existent UID, but since that would/should require changing quite a lot of call sites I settled for this for now.The fact that the LSP server is running every GDScript string literal through
FileAccess::file_exists
is maybe a bit questionable as well, but that seems like more of a performance concern than anything else.FileAccess::file_exists
should not throw errors on non-existent UIDs.