ThinkR-open / ThinkR-open/datadiff
[bug] Comparaison positionnelle à effectifs inégaux : message puis crash R opaque au lieu d'une erreur propre
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Contexte
Sur le chemin positionnel (sans clé), quand les deux datasets n'ont pas le même nombre de lignes, compare_datasets_from_yaml() émet message(error_msg_no_key) puis crashe sur la boucle d'affectation qui suit (cmp[[paste0(c, ref_suffix)]] <- data_reference_p[[c]]) avec une erreur R brute du type replacement has X rows, data has Y (R/compare_datasets_from_yaml.R:430-436). Le test l'assume explicitement (test-edge-cases.R:798-799 : « message emitted then R errors on column assignment »).
Le paramètre error_msg_no_key — exposé dans l'API — alimente donc un simple message() informatif juste avant un plantage non contrôlé, au lieu d'être le texte de l'erreur.
Reprex
library(datadiff)
ref <- data.frame(x = 1:3)
cand <- data.frame(x = 1:2)
compare_datasets_from_yaml(ref, cand)
#> key is missing
#> <message error_msg_no_key>
#> Error in `[[<-`(...) : replacement has 3 rows, data has 2 # opaque
Critères de succès
- Effectifs inégaux sans clé →
stop(error_msg_no_key)(erreur franche, actionnable, mentionnant les deux effectifs), plus aucun crash d'affectation. - La doc du paramètre
error_msg_no_keyreflète son rôle réel (texte de l'erreur). - Test
expect_error()remplaçant l'assertion actuelle de test-edge-cases.R:798-799. - Bonus perf sur le chemin positionnel valide : remplacer la boucle
cmp[[...]] <-par un bind unique (même pattern que tolerance.R).
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.
Research direction
Start in R/compare_datasets_from_yaml.R:430-436 and run the positional unequal-row case from test-edge-cases.R:798-799. Update the behavior and the error_msg_no_key documentation, then replace the existing expectation with expect_error() and verify the valid positional path remains covered. The optional performance improvement is described using the bind pattern in tolerance.R.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data, documentation, performance, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100