Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Schema Inaccuracy] "Add labels to an issue" requestBody and description incorrect

Aperta
#3,366 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia individuando la definizione OpenAPI per POST /repos/{owner}/{repo}/issues/{issue_number}/labels e confronta i relativi schemi e le descrizioni di requestBody con il comportamento documentato in questa issue. Il lavoro è completo quando la descrizione dell’endpoint, le forme accettate e i vincoli minItems riflettono accuratamente il comportamento osservato dell’API.

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

Descrizione

feature fundamentals-and-support inaccuracy rest-schema shield waiting for review

Schema Inaccuracy

For POST /repos/{owner}/{repo}/issues/{issue_number}/labels, the description is currently

Adds labels to an issue. If you provide an empty array of labels, all labels are removed from the issue.

and the requestBody is documented as

The names of the labels to add to the issue's existing labels. You can pass an empty array to remove all labels. Alternatively, you can pass a single label as a string or an array of labels directly, but GitHub recommends passing an object with the labels key. You can also replace all of the labels for an issue. For more information, see "Set labels for an issue.

and the schema specifies, in effect:

  1. a lone $string
  2. an array of $strings
  3. an array of {name: $string}
  4. an object with a single property labels whose value is an array of strings
  5. an object with a single property labels whose value is an array of {name: $string}

incorrect description

First off, the descriptions (of both the endpoint and the requestBody) assert that passing an empty array will remove all the labels, this does not happen, it may have been copied over from the "set labels for an issue" endpoint.

incorrect minItems

On every array, the schema declares minItems: 1, this seems to be untrue for form (2) / (3) which does accept an empty array (it just does nothing), it is true for form 4/5

(1) is not valid

Trying to pass a naked string to the endpoint results in a validation error:

r = session.post(
    f'{pr.issue_url}/labels',
    json="test",
)

=>

{"message":"Invalid request.\n\nNo subschema in \"anyOf\" matched.\nFor 'anyOf/0', \"test\" is not an array.\nFor 'anyOf/1', \"test\" is not an array.\nFor 'anyOf/2', \"test\" is not an object.","documentation_url":"https://docs.github.com/rest/issues/labels#add-labels-to-an-issue"}

(5) is not valid

Trying to pass a nested record results in a validation error:

r = session.post(
    f'{pr.issue_url}/labels',
    json={"labels": [{"name": "test"}]},
)

=>

{"message":"Invalid request.\n\nNo subschema in \"anyOf\" matched.\nFor 'anyOf/0', {\"labels\"=>[{\"name\"=>\"test\"}]} is not an array.\nFor 'anyOf/1', {\"labels\"=>[{\"name\"=>\"test\"}]} is not an array.\nFor 'items', {\"name\"=>\"test\"} is not a string.","documentation_url":"https://docs.github.com/rest/issues/labels#add-labels-to-an-issue"}
Lingua principale
Nessun dato sulla lingua
Stelle
1.6k
Fork
342
Merge medio
2h 23m
PR unite (30g)
57

Guida per i contributori

Apri la guida per i contributori

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 github/rest-api-description

Tutte le issue di github/rest-api-description

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.