gr2m / gr2m/github-project

Throw helpful error when `number` option is invalid

Đang mở
#22 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug good first issue Pull Request welcome
Ngôn ngữ chính
JavaScript
Star
36
Fork
10
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Please avoid duplicates

- [X] I checked [all open bugs](https://github.com/gr2m/github-project/issues?q=is%3Aissue+is%3Aopen+label%3Abug) and none of them matched my problem.

### Reproducible test case

_No response_

### Please select the environment(s) that are relevant to your bug report

- [X] Browsers
- [X] Node
- [X] Deno

### Versions

any

### What happened?

I received the following cryptic error

```
/[path]/node_modules/@octokit/graphql/dist-node/index.js:81
throw new GraphqlResponseError(requestOptions, headers, response.data);
^

GraphqlResponseError: Request failed due to following response errors:
- Variable $number of type Int! was provided invalid value
at /[path]/node_modules/@octokit/graphql/dist-node/index.js:81:13
at async getStateWithProjectItems (file:///[path]/node_modules/github-project/api/lib/get-state-with-project-items.js:22:7)
at async updateItemByContentId (file:///[path]/node_modules/github-project/api/items.update-by-content-id.js:23:26)
at async run (file:///[path]/actions/automate-type-labels/automate-type-labels.js:208:3) {
request: {
query: '\n' +
' query getProjectWithItems($org: String!,$number: Int!) {\n' +
' organization(login: $org) {\n' +
' projectNext(number: $number) {\n' +
' \n' +
' id\n' +
' title\n' +
' description\n' +
' url\n' +
' fields(first: 50) {\n' +
' nodes {\n' +
' id\n' +
' name\n' +
' settings\n' +
' }\n' +
' }\n' +
'\n' +
' items(first: 100) {\n' +
' nodes {\n' +
' \n' +
' id\n' +
' \n' +
' content {\n' +
' __typename\n' +
' ... on Issue {\n' +
' \n' +
' id\n' +
' number\n' +
' title\n' +
' createdAt\n' +
' databaseId\n' +
' assignees(first:10) {\n' +
' nodes {\n' +
' login\n' +
' }\n' +
' }\n' +
' labels(first:10){\n' +
' nodes {\n' +
' name\n' +
' }\n' +
' }\n' +
' closed\n' +
' closedAt\n' +
' createdAt\n' +
' milestone {\n' +
' number\n' +
' title\n' +
' state\n' +
' }\n' +
' repository {\n' +
' name\n' +
' }\n' +
'\n' +
' }\n' +
' ... on PullRequest {\n' +
' \n' +
' id\n' +
' number\n' +
' title\n' +
' createdAt\n' +
' databaseId\n' +
' assignees(first:10) {\n' +
' nodes {\n' +
' login\n' +
' }\n' +
' }\n' +
' labels(first:10){\n' +
' nodes {\n' +
' name\n' +
' }\n' +
' }\n' +
' closed\n' +
' closedAt\n' +
' createdAt\n' +
' milestone {\n' +
' number\n' +
' title\n' +
' state\n' +
' }\n' +
' repository {\n' +
' name\n' +
' }\n' +
'\n' +
' merged\n' +
' }\n' +
' }\n' +
'\n' +
' fieldValues(first: 20) {\n' +
' nodes {\n' +
' value\n' +
' projectField {\n' +
' id\n' +
' }\n' +
' }\n' +
' }\n' +
'\n' +
' }\n' +
' }\n' +
' }\n' +
' }\n' +
' }\n',
variables: { org: 'my-org', number: NaN }
},
headers: {
'access-control-allow-origin': '*',
'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
connection: 'close',
'content-encoding': 'gzip',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Wed, 09 Mar 2022 01:20:24 GMT',
'github-authentication-token-expiration': '2022-04-04 21:49:00 UTC',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'GitHub.com',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
'transfer-encoding': 'chunked',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-accepted-oauth-scopes': 'repo',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-media-type': 'github.v3; format=json',
'x-github-request-id': 'F6D7:7E08:1B40BEB:37F130A:622800D7',
'x-oauth-scopes': 'notifications, repo',
'x-ratelimit-limit': '5000',
'x-ratelimit-remaining': '5000',
'x-ratelimit-reset': '1646792424',
'x-ratelimit-resource': 'graphql',
'x-ratelimit-used': '0',
'x-xss-protection': '0'
},
response: {
errors: [
{
extensions: { value: null, problems: [ [Object] ] },
locations: [ { line: 2, column: 43 } ],
message: 'Variable $number of type Int! was provided invalid value'
}
]
},
errors: [
{
extensions: {
value: null,
problems: [ { path: [], explanation: 'Expected value to not be null' } ]
},
locations: [ { line: 2, column: 43 } ],
message: 'Variable $number of type Int! was provided invalid value'
}
],
data: undefined
}
```

What I expected instead is that the `new Project()` constructor should throw immediately when an invalid number was passed

### Would you be interested in contributing a fix?

- [ ] yes

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu từ constructor `new Project()` và theo dõi cách tùy chọn `number` của nó đến được request GitHub Projects được hiển thị trong stack trace. Xác nhận rằng constructor xử lý ngay một số không hợp lệ và kiểm tra rằng các số project hợp lệ vẫn đến request một cách chính xác.

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

Đánh giá

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

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.