Informative error for `api()`

Aperta
#76 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r
Ambito
api

Direzione di ricerca

Start by reproducing the failure with an empty R/api.R and _server.yml using plumber2::api(), after generating the project with create_server_yml("R/api.R"). Trace the api() entry point to find where the route definitions are read; done means an empty route file produces a clear error explaining that no routes are defined.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 !

Lingua principale
R
Stelle
119
Fork
17
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di posit-dev/plumber2

Tutte le issue di posit-dev/plumber2

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.