Clearer error when include*() helpers are given a missing file#448
Merged
schloerke merged 8 commits intoMay 27, 2026
Merged
Conversation
Check file.exists(path) up front and raise a structured rlang::abort() naming the missing file, instead of letting readLines() surface the generic "cannot open the connection" message.
Factor the file.exists() check into check_include_path() and apply it to includeHTML(), includeText(), includeMarkdown(), and includeScript() so they all raise a clear error naming the missing path, matching the behavior just added to includeCSS().
Verify includeCSS(), includeHTML(), includeText(), includeMarkdown(), and includeScript() each raise a clear error naming both the file type and the missing path when given a non-existent file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
schloerke
reviewed
May 27, 2026
Move skip_if_not_installed("markdown") into its own test_that() so the
skip sits at the top of the test, and remove the second test that only
re-checked includeCSS().
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pass call = rlang::caller_env() into rlang::abort() so the error header reads "Error in includeCSS():" (or the relevant helper) rather than "Error in check_include_path():", making the source of the problem easier for users to find. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Guard check_include_path() against two edge cases that previously surfaced confusing errors: - NULL, character(0), multi-element vectors, "", and NA_character_ inputs now raise a clear "path must be a single non-empty string" message instead of "argument is of length zero" from file.exists(). - A directory at `path` now raises the same "does not exist" error instead of the cryptic message from readLines(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
|
Failing checks are unrelated to PR. Waiting for fixes before merging |
schloerke
approved these changes
May 27, 2026
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 rstudio/shiny#1757
Summary
includeCSS(),includeHTML(),includeText(),includeMarkdown(), andincludeScript()previously surfaced the genericcannot open the connectionmessage fromreadLines()when given a non-existentpath.file.exists()check via a new internal helpercheck_include_path(), which raises a structuredrlang::abort()naming the missing file.NEWS.mdupdated.Test plan
devtools::test()passes