Skip to content

Improve facet error messages in animint2dir#285

Open
ANAMASGARD wants to merge 14 commits into
masterfrom
fix-168-facet-error-message
Open

Improve facet error messages in animint2dir#285
ANAMASGARD wants to merge 14 commits into
masterfrom
fix-168-facet-error-message

Conversation

@ANAMASGARD
Copy link
Copy Markdown
Contributor

@ANAMASGARD ANAMASGARD commented Dec 21, 2025

FIXES #168

What's broken

viz <- list(
  plot = ggplot() + 
    facet_wrap(. ~ Species) +  # formula notation
    geom_point(aes(x, y), data = iris)
)
animint2dir(viz) 
  • Current error:
    Error: At least one layer must contain all variables used for facetting

Doesn't tell you what's wrong or how to fix it.

  • Workaround that works:
    facet_wrap("Species") # string notation works fine

What I am fixing

  1. Detect when formula notation is used in facets
  2. Give clear error telling user to use string notation instead
  3. Fix happens in animint2dir() - animint2-specific code only

Next commit will add the fix to make tests pass.

Issue #168 - facet_wrap(. ~ var) gives unhelpful error when var is missing.

Added tests that will pass once we improve error messages in animint2dir().
Tests cover facet_wrap and facet_grid with missing variables.

These tests are animint2-specific .
When facet_wrap or facet_grid uses formula notation with a variable
that does not exist in the data, the error now shows:
- Which variable is missing
- What columns are available
- Suggests using string notation instead

Fixes #168
@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

ANAMASGARD commented Dec 22, 2025

Before :-

Error: At least one layer must contain all variables used for facetting

After :-

Error: Facet variable not found in data: MissingVar
Available columns: Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species
Use string notation like facet_wrap("var") instead of formula notation facet_wrap(. ~ var) ```

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.04%. Comparing base (a4220df) to head (d719de1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #285      +/-   ##
==========================================
+ Coverage   73.02%   73.04%   +0.02%     
==========================================
  Files         164      164              
  Lines        8837     8845       +8     
==========================================
+ Hits         6453     6461       +8     
  Misses       2384     2384              
Flag Coverage Δ
javascript 81.23% <ø> (ø)
r 69.18% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tdhock
Copy link
Copy Markdown
Collaborator

tdhock commented Dec 22, 2025

No obvious timing issues in HEAD=fix-168-facet-error-message
Comparison Plot

Generated via commit c1877ef

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 2 minutes and 12 seconds
Installing different package versions 27 seconds
Running and plotting the test cases 3 minutes and 29 seconds

@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Sir @tdhock The 2 failing tests in JS_coverage are in test-compiler-ghpages.R (GitHub Pages tests), not related to this PR. This is the same race condition issue where parallel CI jobs conflict over the shared test repository.

All facet-related tests pass:

  • R_coverage: 2096+ tests passed
  • CRAN: passed
  • My 3 new facet error message tests pass

The fix is working correctly. Please review and give your feedback Sir .

@ANAMASGARD ANAMASGARD requested a review from tdhock December 22, 2025 10:04
Comment thread tests/testthat/test-renderer-facet-error-messages.R Outdated
Comment thread R/z_animintHelpers.R Outdated
@ANAMASGARD ANAMASGARD requested a review from tdhock March 18, 2026 03:30
Comment thread R/facet-layout.r Outdated
@ANAMASGARD ANAMASGARD requested a review from tdhock May 26, 2026 15:20
Comment thread R/z_animintHelpers.R Outdated
Comment thread R/facet-layout.r Outdated
@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Also Sir @tdhock atime performance tests / comment job failing actually has nothing to do with this PR :

  • It installs animint2 from an old baseline commit to compare performance before and after my changes
  • The baseline commit it is using is 352f7e1 (version 2025.9.16)

Where it crashes:

It crashes during R CMD INSTALL of that old commit with this error:

Error: geom_dotplot.Rd:125: processing build-stage \Sexpr code failed:
Error: No geom called GeomDotplot.
ERROR: installing Rd objects failed
Error in atime_versions_install(...) :
  '/opt/R/4.6.0/lib/R/bin/R' CMD INSTALL returned error status code 1 

Why does this happen:

  • That old commit's geom_dotplot.Rd has a \Sexpr line that looks up GeomDotplot at build time
  • GeomDotplot was removed from animint2 after that commit
  • So the old doc file now breaks when installed under R 4.6.0
  • The current man/geom_dotplot.Rd on master is already fixed — this is only broken in that old commit

My changes are never even reached — the job dies at install time before running any performance tests.

There is also this warning in the log:

Warning: CRAN version=2025.10.17 but installed version=2026.2.28
fix via install.packages('animint2') 

This is an infrastructure/CI issue, not a code issue. Can you please tell what should I do not it is happening in my other PR's also .

@ANAMASGARD ANAMASGARD requested a review from tdhock May 26, 2026 17:17
Comment thread R/facet-layout.r Outdated
Comment thread R/facet-layout.r Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

facet_wrap ~var errors but "var" works

2 participants