Fix internal error in pivot_wider() when id_cols selects non-existent columns#17
Draft
Fix internal error in pivot_wider() when id_cols selects non-existent columns#17
pivot_wider() when id_cols selects non-existent columns#17Conversation
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Solve upstream issue @tidyverse/tidyr/issues/1609 .
Fix internal error in Sep 19, 2025
pivot_wider() when id_cols selects non-existent columns
Copilot stopped work on behalf of
krlmlr due to an error
September 19, 2025 14:03
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 tidyverse#1609 and tidyverse#1482 where
pivot_wider()would crash with an internal error whenid_colstries to select columns that don't exist or were removed bynames_from.Problem
The
rethrow_id_cols_oob()function contained acheck_string(i, .internal = TRUE)call that expected the column identifierito always be a single string. However, when tidyselect fails to find columns, it can return integer vectors or character vectors instead, causing an internal error:Solution
Following @DavisVaughan's suggestion in tidyverse#1609, the fix makes the error handling more robust by:
check_string()call that was causing crashesiis actually a string usingis_string(i)Result
The same code now produces a proper tidyselect error instead of crashing:
This change maintains backward compatibility - string inputs still receive the same custom error messages as before, while vector inputs now get appropriate tidyselect errors instead of internal crashes.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cloud.r-project.org/usr/lib/R/bin/exec/R -e install.packages('testthat',~+~repos~+~=~+~'REDACTED')(dns block)esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.