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

SchemaValidator rejects nested empty JSON objects as arrays

Aperta
#586 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
60/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Start in the SchemaValidator class at its validateAgainstJsonSchema method, and find where it converts an empty root value to stdClass. Run the reproduction from the issue, which decodes '{"parameters":{}}' with the parameters property typed as object, and confirm the nested empty array is rejected. Done means the nested empty value is cast to stdClass when the schema says object, with a regression test for that case and the existing root-level behaviour still passing.

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

Descrizione

bug

Describe the bug
Nested empty objects in tool arguments are rejected as arrays.

To Reproduce

use Mcp\Capability\Discovery\SchemaValidator;

$data = json_decode(
    '{"parameters":{}}',
    true,
    flags: JSON_THROW_ON_ERROR,
);

$schema = [
    'type' => 'object',
    'properties' => [
        'parameters' => ['type' => 'object'],
    ],
];

// Invalid type. Expected `object`, but received `array`.
var_dump((new SchemaValidator())->validateAgainstJsonSchema($data, $schema));

Expected behavior
No validation errors. The original JSON value is an object.

Additional context
json_decode($foo, true) converts both {} and [] to an empty PHP array. The SchemaValidator converts an empty root value to stdClass, but nested empty values remain arrays. The empty arrays should probably be converted recursively according to the schema.

Lingua principale
PHP
Stelle
1.6k
Fork
180
Merge medio
2g 16h
PR unite (30g)
36

Preparare l'ambiente

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 modelcontextprotocol/php-sdk

Tutte le issue di modelcontextprotocol/php-sdk

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.