Potentially address subtle bug with file paths getting a trailing slash#161
Merged
BenjaminAmos merged 2 commits intotemp/terasology-gestalt-di-migration-changesfrom Dec 14, 2025
Merged
Conversation
Member
Author
|
... I did not realize just linking my GitHub with Cursor would auto-enable Bugbot here but alright, cool, till I run out of quota I guess 🤔 |
BenjaminAmos
approved these changes
Nov 30, 2025
Contributor
BenjaminAmos
left a comment
There was a problem hiding this comment.
These changes make sense to me. Since the changes only affect an internal helper method, this should not break anything.
2d99dbb
into
temp/terasology-gestalt-di-migration-changes
7 checks passed
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 new Antigravity IDE by Google and Gemini 3 Pro found this one while I was trying to write Terasology tests validating various ways to get resources. It sounded reasonable and tested out - will let the AI explain further! Leaving this in a PR just so I don't forget the what and why, it doesn't need to merge any time soon.
Explanation of the Gestalt Fix
The issue was in ClasspathFileSource.buildPathString(), which was unconditionally appending a slash (/) to the path.
Is it safe? Yes. getFile() returns a FileReference, which is intended for reading files (it has an open() method for streams). It is not typically used for directories. Even if it were, ClassLoader.getResource generally handles directory paths without trailing slashes correctly anyway. The fix simply constructs the path exactly as requested for getFile, bypassing the directory-oriented helper.
Note
Adjusts
ClasspathFileSourceto only append a trailing slash for directories, not files.ClasspathFileSource:buildPathString(List<String> path)tobuildPathString(List<String> path, boolean isDirectory).getFile(...)now callsbuildPathString(..., false)(no trailing slash for files).getFilesInPath(...)andgetSubpaths(...)now callbuildPathString(..., true)(trailing slash for directories)."/"only whenisDirectoryis true.Written by Cursor Bugbot for commit e309888. This will update automatically on new commits. Configure here.