sncf-connect-tech / hesperides

Configuration management tool providing universal text file templating and properties editing through a REST API or a webapp (backend part)
https://voyages-sncf-technologies.github.io/hesperides-gui/
GNU General Public License v3.0
36 stars 28 forks source link

Lors de la sauvegarde de template, on ne valide pas qu'une propriété simple ne doit pas avoir le même nom qu'une propriété itérable #701

Closed lenaing closed 5 years ago

lenaing commented 5 years ago

Exemple de template:

{{#appenders.file-rolling-vsctlayout}}
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="{{appendername}}">
        <File>${log.instance.dir}/espaceclient/{{filename}}.log</File>
        <Append>true</Append>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>{{roll.threshold|@comment "taille du fichier déclenchant une rotation (kilo-octet)" @default 5000}}KB</maxFileSize>
        </triggeringPolicy>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>${log.instance.dir}/espaceclient/{{filename}}.log-%i</fileNamePattern>
            <maxIndex>{{roll.max-index|@comment "nombre maximal de fichiers '.log-%i'" @default 5}}</maxIndex>
        </rollingPolicy>
        <Encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
            <layout class="com.vsct.component.log.layout.logback.VsctLayout"/>
        </Encoder>
    </appender>
{{/appenders.file-rolling-vsctlayout}}

Mon iterable : {{appenders.file-rolling-vsctlayout}}

Stacktrace:

2019-07-18 15:29:53.376 ERROR 11312 --- [nio-8080-exec-5] o.h.c.p.e.GlobalExceptionHandler         : Unexpected error (path=uri=/rest/applications/KTN/platforms/KTN1/properties):
2019-07-18 15:29:53.378 ERROR 11312 --- [nio-8080-exec-5] o.h.c.p.e.GlobalExceptionHandler         : java.lang.ClassCastException: org.hesperides.core.domain.templatecontainers.queries.PropertyView cannot be cast to org.hesperides.core.domain.templatecontainers.queries.IterablePropertyView

java.lang.ClassCastException: org.hesperides.core.domain.templatecontainers.queries.PropertyView cannot be cast to org.hesperides.core.domain.templatecontainers.queries.IterablePropertyView
    at org.hesperides.core.domain.platforms.queries.views.properties.IterableValuedPropertyView.excludePropertyWithOnlyDefaultValue(IterableValuedPropertyView.java:59)
    at org.hesperides.core.domain.platforms.queries.views.properties.AbstractValuedPropertyView.lambda$excludePropertiesWithOnlyDefaultValue$2(AbstractValuedPropertyView.java:88)
Lucas-C commented 5 years ago

Cette vérification pourrait être faite dans PlatformUseCases.getValuedProperties, avant l'appel à excludePropertiesWithOnlyDefaultValue qui lève cette exception

Réflexion faite, on veut détecter ce cas lors des opérations de création de template / MAJ de template

Lucas-C commented 5 years ago

Il serait très intéressant d'avoir un test BDD pour ce type de cas, car c'est un "trou dans la raquette" du même type que ceux identifiés dans https://github.com/voyages-sncf-technologies/hesperides/issues/705 &https://github.com/voyages-sncf-technologies/hesperides/issues/648 & https://github.com/voyages-sncf-technologies/hesperides/issues/505 & https://github.com/voyages-sncf-technologies/hesperides/issues/89

Lucas-C commented 5 years ago

Petite analyse des modifications à apporter pour corriger ce bug "proprement" (validée avec @thomaslhostis) :

Lucas-C commented 5 years ago

CR de notre discussion là-dessus à l'instant avec @thomaslhostis & @lenaing

tl,pl : refacto trop couteux en temps à réaliser, et "risqué" en terme d'impact -> on n'attaque pas le sujet maintenant

Issue dédiée : https://github.com/voyages-sncf-technologies/hesperides/issues/744