Skip to content

Don't check path as part of resource() #285

Description

@peterdesmet

We want resource() to be a public accessor function (see #283). That function currently makes a number of checks, including whether the path has an accessible file:

if (is.null(resource$path) && is.null(resource$data)) {
cli::cli_abort(
"Resource {.val {resource_name}} must have a {.field path} or
{.field data} property.",
class = "frictionless_error_resource_without_path_data"
)
}

We might want to move that check a bit closer to reading the data, not when just accessing the resource.

The use case comes from the etn R package, where we have a datapackage.json file that acts as a template for creating Data Packages. The paths in that file don't refer to paths until data is written. Because of check_path(), accessor functions like schema() or resource() return an error:

library(frictionless)
(p <- read_package("https://raw.githubusercontent.com/inbo/etn/refs/heads/main/inst/assets/datapackage.json"))
#> A Data Package with 5 resources:
#> • animals
#> • tags
#> • detections
#> • deployments
#> • receivers
#> Use `unclass()` to print the Data Package as a list.

get_schema(p, "animals")
#> Error in `purrr::map_chr()` at frictionless-r/R/get_resource.R:60:7:
#> ℹ In index: 1.
#> Caused by error in `check_path()`:
#> ! Can't find file at
#>   <https://raw.githubusercontent.com/inbo/etn/refs/heads/main/inst/assets/animals.csv>.

Created on 2025-10-07 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions