ThinkR-open / ThinkR-open/datadiff

[bug] Comparaison positionnelle à effectifs inégaux : message puis crash R opaque au lieu d'une erreur propre

Open
#15 0 comments 0 reactions 0 assignees View on GitHub

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_key reflè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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.