gr2m / gr2m/github-project

Throw helpful error when `number` option is invalid

Abierto
#22 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug good first issue Pull Request welcome
Lenguaje dominante
JavaScript
Estrellas
36
Forks
10
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### 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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.