Projet

Général

Profil

Bug #81643

soap: boucle infinie possible dans type2schema

Ajouté par Thomas Noël il y a 7 mois. Mis à jour il y a 7 mois.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
26 septembre 2023
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Non
Planning:
Non

Description

Sur un schéma avec une référence récursive du type :

      <xsd:complexType name="refVal">
        <xsd:sequence>
          <xsd:element name="actif" type="xsd:boolean"/>
          <xsd:element name="code" type="xsd:string" minOccurs="0"/>
          <xsd:element name="id" type="xsd:long"/>
          <xsd:element name="libelle" type="xsd:string" minOccurs="0"/>
          <xsd:element name="libelleLong" type="xsd:string" minOccurs="0"/>
          <xsd:element name="oldId" type="xsd:long"/>
          <xsd:element name="ordre" type="xsd:short" minOccurs="0"/>
          <xsd:element name="pere" type="tns:refVal" minOccurs="0"/>        <--- refVal dans refVal
          <xsd:element name="refTab" type="tns:refTab" minOccurs="0"/>
        </xsd:sequence>
      </xsd:complexType>

ça se termine sur un crash (caché par un try/except ValidationError) :

RecursionError at /manage/soap/add

maximum recursion depth exceeded while getting the str of an object

Request Method:     POST
Request URL:     https://passerelle.dev.publik.love/manage/soap/add
Django Version:     3.2.18
Exception Type:     RecursionError
Exception Value:     

maximum recursion depth exceeded while getting the str of an object

Exception Location:     /home/thomas/src/passerelle/passerelle/apps/soap/models.py, line 225, in type2schema

C'est dans type2schema qu'on a un appel récursif qui peut boucler :

        elif isinstance(xsd_type, zeep.xsd.ComplexType):
            properties = collections.OrderedDict()
            schema = {
                'type': 'object',
                'properties': properties,
            }
            for key, element in xsd_type.elements:
                if element.min_occurs > 0:
                    schema.setdefault('required', []).append(key)
                element_schema = self.type2schema(element.type, compress=compress)    <--- ici, il faudrait "contrôler" 
                if element.max_occurs == 'unbounded' or element.max_occurs > 1:
                    element_schema = {'type': 'array', 'items': element_schema}
                properties[key] = element_schema
            if not properties:
                schema = {'type': 'null'}

Révisions associées

Révision 8266740b (diff)
Ajouté par Benjamin Dauvergne il y a 7 mois

soap: handle recursive complexType (#81643)

Reference to already converted complexType are converted to JSON schema
references.

Révision a9f2956d (diff)
Ajouté par Benjamin Dauvergne il y a 7 mois

templatags: rendering of $id/$ref in jsonschema (#81643)

Historique

#2

Mis à jour par Thomas Noël il y a 7 mois

  • Description mis à jour (diff)
#3

Mis à jour par Benjamin Dauvergne il y a 7 mois

  • Assigné à mis à Benjamin Dauvergne
#5

Mis à jour par Robot Gitea il y a 7 mois

  • Statut changé de Nouveau à Solution proposée

Benjamin Dauvergne (bdauvergne) a ouvert une pull request sur Gitea concernant cette demande :

#6

Mis à jour par Robot Gitea il y a 7 mois

  • Statut changé de Solution proposée à En cours

Thomas NOËL (tnoel) a relu et demandé des modifications sur une pull request sur Gitea concernant cette demande :

#7

Mis à jour par Benjamin Dauvergne il y a 7 mois

  • Statut changé de En cours à Solution proposée
#8

Mis à jour par Robot Gitea il y a 7 mois

  • Statut changé de Solution proposée à Solution validée

Thomas NOËL (tnoel) a approuvé une pull request sur Gitea concernant cette demande :

#9

Mis à jour par Robot Gitea il y a 7 mois

  • Statut changé de Solution validée à Résolu (à déployer)

Benjamin Dauvergne (bdauvergne) a mergé une pull request sur Gitea concernant cette demande :

#10

Mis à jour par Transition automatique il y a 7 mois

  • Statut changé de Résolu (à déployer) à Solution déployée
#11

Mis à jour par Transition automatique il y a 5 mois

Automatic expiration

Formats disponibles : Atom PDF