Informative error for `api()`

Đang mở
#76 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
r
Lĩnh vực
api

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 !

Ngôn ngữ chính
R
Star
119
Fork
17
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của posit-dev/plumber2

Tất cả issue của posit-dev/plumber2

Issue tương tự

Thêm issue về R

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.