Skip to content

Informative error for api() #76

@paul-carteron

Description

@paul-carteron

Hi,

As a first-time user of plumber2, I got stuck for quite a while when trying to
set up a minimal API using:

plumber2::create_server_yml("R/api.R")
plumber2::api("_server.yml")

Project structure:

test_plumber/
├─ Dockerfile
├─ _server.yml
├─ R/
│  └─ api.R

When R/api.R is empty, calling api("_server.yml") fails with the following

Error in seq_len(which(grepl("^(?!#('|\\*))", lines, perl = TRUE))[1] - 1) :
  argument must be coercible to a non-negative integer

The error is not very informative and makes it hard for new users to understand what is wrong. In this case, the root cause is simply that R/api.R does not define any routes.

It might be helpful to return a clearer error message to improve the experience for new users.

Thanks for the great work on plumber2 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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