hash_obj_*()/hash_raw_*() variants don't validate parameter bounds, unlike their base hash_*() counterparts (affects animal and emoji hashes)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in R/hash.R with hash_animal(), hash_raw_animal(), hash_emoji(), and hash_raw_emoji(), comparing the parameter checks in the base functions with their raw variants; the object variants call the raw functions. Confirm the documented bounds and make the behavior consistent across each function family, then verify invalid n_adj and size values are handled consistently.
Written by the indexing model from the issue text.
Description
For both the adjective-animal hash and the emoji hash families, the "base" function validates its size-related parameter, but the raw and obj variants do not — despite sharing the same documented constraints.
1. hash_animal() family — n_adj (documented: "must be from 0 through 3")
r
cli::hash_animal("test", n_adj = 9)
#> Error: n_adj >= 0 && n_adj <= 3 is not TRUE
cli::hash_obj_animal("test", n_adj = 9)
#> runs without error
cli::hash_raw_animal(as.raw(1:4), n_adj = 9)
#> runs without error
2. hash_emoji() family — size (documented: "currently it has to be from 1 through 4")
r
cli::hash_emoji("test", size = 9)
#> Error: size >= 1 && size <= 4 is not TRUE
cli::hash_obj_emoji("test", size = 9)
#> runs without error
cli::hash_raw_emoji(as.raw(1:4), size = 9)
#> runs without error
Question / request
Please confirm if the documented note (that these parameters "must be" within the stated range) is correct and the code needs a fix to enforce it consistently — or if the intended behavior is looser than documented and the documentation needs an update instead.
Where this comes from
In R/hash.R:
hash_animal() has a stopifnot() checking n_adj; hash_raw_animal() (and by extension hash_obj_animal(), which calls it) only checks is.raw(x).
hash_emoji() has a stopifnot() checking size; hash_raw_emoji() (and by extension hash_obj_emoji()) only checks is.raw(x).
- Dominant language
- R
- Stars
- 726
- Forks
- 94
- Avg merge
- 3h 35m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from r-lib/cli
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
feature
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
Similar issues
-
documentation pkg infrastructure
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
epiverse-trace/epiparameter#511 ·
-
function:write_dwc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Urgent request: Due to vulnerabilities move to API version 12.6.1 (12.6.2 eventually) or 13.1.1 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
jbkunst/highcharter#849 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100