gr2m / gr2m/github-project

Throw helpful error when `number` option is invalid

Ouverte
#22 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug good first issue Pull Request welcome
Langage dominant
JavaScript
Étoiles
36
Forks
10
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par le constructeur `new Project()` et suivez comment son option `number` atteint la requête GitHub Projects affichée dans la stack trace. Confirmez que le constructeur gère immédiatement un numéro invalide et vérifiez que les numéros de projet valides atteignent toujours correctement la requête.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript
Domaine
api
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.