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

Fatal Error due to Force-Unwrapping in CoreBPE.bytePairEncode(piece: ranks:) #5

Open
gdbing opened this issue Feb 1, 2024 · 0 comments

Comments

@gdbing
Copy link

gdbing commented Feb 1, 2024

Load.fetch(stringURL:) method invokes try await URLSession.shared.data(from: url) to fetch encoder the first time it is used. If an error occurs (e.g., the method is invoked without networking permissions), it throws an exception.

In the calls to the fetch method, this exception is handled with try?, substituting an empty collection [:] when an error is caught.

In the CoreBPE.bytePairEncode(piece: ranks:) method, there's a force-unwrapping operation return [ranks[piece]!], which causes a fatal error if ranks is an empty collection.

Recommendation: Catching an error from Load.fetch(stringURL:) should fail more decisively, halting execution, instead of progressing with an empty encoder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant