Validate BotMaker collection function inputs - #62
Open
exocognosis wants to merge 1 commit into
Open
Conversation
exocognosis
marked this pull request as ready for review
August 15, 2026 15:36
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.
Summary
First()with a clearIllegalArgumentException.FirstN()count to the valid range from zero through the list size.Slice()range before callingsubstring()orsubList().Problem
The collection functions passed unchecked values to Java APIs. This exposed implementation exceptions such as
IndexOutOfBoundsExceptionandIllegalArgumentExceptionwithout BotMaker-specific context.FirstN()also converted aLongto anintbefore it applied bounds. Large values could therefore wrap before validation.Solution
First()now detects an empty list before it reads index zero. It reports that the function requires a non-empty list.FirstN()now clamps the requested count while it is still along. A negative count returns an empty view. A count greater than the list size returns the full list. This also handlesLong.MIN_VALUEandLong.MAX_VALUEwithout integer wraparound.Slice()now checks that the start index is non-negative, the end index is not less than the start index, and the end index does not exceed the input length. The check runs before either index is converted to anint. Invalid string and list ranges now produce the same error format with the requested range and input length.Validation
git diff --check.Long.MIN_VALUE, andLong.MAX_VALUEcounts.The public repository snapshot does not include a root build workspace or an externally resolvable BotMaker dependency graph. A complete BotMaker target build is therefore not available from this checkout.
Fixes #58