Repository navigation
MOD-21733: Reject non-integer JSON.ARRPOP index - #1724
Open
AvivDavid23 wants to merge 1 commit into
Open
AvivDavid23 wants to merge 1 commit into
AvivDavid23 wants to merge 1 commit into
Conversation
A supplied index that failed to parse was treated as -1, so the command popped the last element instead of erroring. Parse the index when present and propagate the error; an omitted index still defaults to -1.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1724 +/- ##
=======================================
Coverage 88.13% 88.13%
=======================================
Files 18 18
Lines 6861 6861
=======================================
Hits 6047 6047
Misses 814 814 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TalBarYakar
approved these changes
Dec 1, 2026
TalBarYakar
left a comment
Contributor
There was a problem hiding this comment.
Seems like a breaking change (although it actually fix a bug)
just notify product on the new approach
This branch has not been deployed
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.
Fixes #1713 (MOD-21733)
Problem
When an explicit
JSON.ARRPOPindex was not an integer, it was treated as-1and the last element was removed:Fix
json_arr_pop_command_implusedargs.next_i64().unwrap_or(-1), which mapped both "no index" and "unparsable index" to-1. It now defaults to-1only when the index is omitted, and propagates the parse error otherwise.Note: a non-integer index now returns
Couldn't parse as integer, and since arguments are parsed before the key is opened, this takes precedence over key/path errors.Test plan
testArrPopNonIntegerIndex:not-an-integer,1.5,''rejected for$and legacy.paths with document unchanged; omitted index still pops the last elementtest_multi.py:testErrorMessage: replaced incidental"abc"index (relied on the old silent-1) with-1; assertions on key/path errors unchangedQUICK=1suite 376/376;cargo clippy/cargo fmt --checkcleanNote
Low Risk
Small argument-parsing fix in one command with targeted tests; behavior change only for invalid explicit indexes.
Overview
JSON.ARRPOP no longer treats a bad index as
-1and pops the last element. Index parsing now follows the same pattern as JSON.ARRINDEX: default to-1only when the argument is omitted, and return a parse error (Couldn't parse as integer) when a value is present but not a valid integer—before the key is opened.Tests add
testArrPopNonIntegerIndex(non-integer and empty index rejected for$and.; document unchanged; omitted index still pops the last).test_multi.pyARRPOP error cases use-1instead of"abc", which previously relied on the silent fallback.Reviewed by Cursor Bugbot for commit 19d7319. Bugbot is set up for automated code reviews on this repo. Configure here.