Skip to content

sess: dataview paging tests fail under R CMD check (rows is a data frame, not a list of rows) #1742

Description

@grantmcdermott

R CMD check sess fails in tests/tinytest.R after 7 passing tests:

test-ipc.R....................    7 tests OK Error in page_res$rows[[1]][["1"]] : subscript out of bounds
Calls: <Anonymous> ... all.equal -> all.equal.character -> attr.all.equal -> mode
Execution halted

Cause

The dataview paging tests index rows as a list of row objects:

https://github.com/REditorSupport/vscode-R/blob/master/sess/inst/tinytest/test-ipc.R#L97

expect_equal(page_res$rows[[1]][["1"]], "3")

But dataview_rows() (sess/R/handlers.R:766) returns a data frame, so rows[[1]] is the first column, not the first row, and [["1"]] on that vector is out of bounds:

df <- data.frame(a = c(3, 1, 2), b = c("x", "y", "z"))
reg <- sess:::dataview_register(df)
p <- sess:::handle_dataview_page(list(
  view_id = reg$view_id, startRow = 0L, endRow = 2L,
  sortModel = list(), filterModel = list()
))
str(p$rows)
#> 'data.frame': 2 obs. of  3 variables:
#>  $ 0: int  1 2
#>  $ 1: num  3 1
#>  $ 2: chr  "x" "y"

The same pattern appears again at test-ipc.R:145 for the sort test.

The returned value looks correct: jsonlite serializes a data frame as an array of row objects, which is the shape the client consumes. So the tests' indexing appears to be what needs fixing, not dataview_rows(). Worth confirming against the client before changing either side.

Why CI didn't catch it

No workflow runs the sess tinytest suite. .github/workflows/main.yml only runs lintr::lint_package("sess") for this package; there is no R CMD check or tinytest step. Adding one would fit the test-coverage goals in #1732.

Other R CMD check findings

Fixed while investigating (uncommitted at time of writing):

  • httpgd used via ::/requireNamespace() but not declared → added to Suggests.
  • .lintr shipped inside the built package → added sess/.Rbuildignore.

Remaining NOTEs, not addressed:

  • getFromNamespace used without import; suggests importFrom("utils", "getFromNamespace").
  • ::: calls into tools/utils internals (escapeAmpersand, print.help_files_with_topic, print.hsearch) and unlockBinding() in R/utils.R. These are inherent to how sess rebinds utils::View and hooks help rendering.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions