ThinkR-open / ThinkR-open/datadiff

[bug] Résolution YAML vs arguments fragile : label écrasé silencieusement, champ « keys » lu par partial matching

Open
#20 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

Deux défauts dans la résolution des règles au début de compare_datasets_from_yaml() :

  1. label ignoré dès que path est fourni : label <- rules$defaults$label écrase inconditionnellement l'argument (R/compare_datasets_from_yaml.R:304). L'argument label n'est honoré que sur la branche auto-YAML (path = NULL, via le template temporaire). Aucun avertissement.
  2. keys vs key : write_rules_template() écrit defaults$keys (l.73) — comme tous les YAML des tests et de la vignette — mais le code lit rules$defaults$key au singulier (l.309). Ça ne fonctionne que grâce au partial matching de $ (vérifié sous R 4.3.3 : list(keys = "id")$key"id", avec warning sous options(warnPartialMatchDollar = TRUE)). Casse le jour où on passe à [[, ou si un YAML contient à la fois key et keys. Le Quick Start du README (appel sans key=) repose entièrement sur ce partial matching.

Reprex

library(datadiff)
ref <- data.frame(id = 1:2, x = 1:2)

path <- tempfile(fileext = ".yaml")
write_rules_template(ref, key = "id", path = path)

# 1. label écrasé
res <- compare_datasets_from_yaml(ref, ref, key = "id", path = path,
                                  label = "Mon label métier")
res$reponse$label      # != "Mon label métier"

# 2. partial matching
options(warnPartialMatchDollar = TRUE)
rules <- read_rules(path)
rules$defaults$key
#> Warning: partial match of 'key' to 'keys'

Critères de succès

  • Précédence documentée et implémentée : argument explicite > YAML > défaut (label <- label %||% rules$defaults$label, idem key).
  • Lecture explicite de rules$defaults$keys (avec rétrocompat key si souhaité), plus aucun partial matching — la suite de tests passe avec options(warnPartialMatchDollar = TRUE) sans warning.
  • Une table « qui gagne ? » (argument vs YAML) dans la doc de compare_datasets_from_yaml() et la vignette.
  • Tests : label explicite conservé avec path fourni ; YAML contenant key et keys simultanément → comportement défini.

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 around lines 304–309, then inspect write_rules_template() and the existing tests and vignette. Run the test suite with warnPartialMatchDollar enabled; done means precedence is covered, keys is read explicitly without warnings, both key forms have defined behavior, and the documentation includes the argument-versus-YAML table.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, yaml
Domain
data, documentation, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.