danger / kotlin

⚠️ Stop saying "you forgot to …" in code review
MIT License
505 stars 50 forks source link

MissingFieldException error in BitBucketServerReviewer #210

Open astoriawinter opened 2 years ago

astoriawinter commented 2 years ago

Hello! I build danger-kotlin from sources, and when I try to run (I use bitbucket) danger-kotlin *stash_pull_request_number* --dangerfile=Dangerfile.df.kts I get such error:

kotlinx.serialization.MissingFieldException: Field 'lastReviewedCommit' is required for type with serial name                 
'systems.danger.kotlin.models.bitbucket.BitBucketServerReviewer', but it was missing
    at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20)
    at systems.danger.kotlin.models.bitbucket.BitBucketServerReviewer.<init>(BitBucketServer.kt:233)
    at systems.danger.kotlin.models.bitbucket.BitBucketServerReviewer$$serializer.deserialize(BitBucketServer.kt:233)
    at systems.danger.kotlin.models.bitbucket.BitBucketServerReviewer$$serializer.deserialize(BitBucketServer.kt:233)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:63)
    at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:32)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
    at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:535)
    at kotlinx.serialization.internal.ListLikeSerializer.readElement(CollectionSerializers.kt:80)
    at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
    at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
    at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:63)
    at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:32)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
    at systems.danger.kotlin.models.bitbucket.BitBucketServerPR$$serializer.deserialize(BitBucketServer.kt:195)
    at systems.danger.kotlin.models.bitbucket.BitBucketServerPR$$serializer.deserialize(BitBucketServer.kt:195)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:63)
    at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:32)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
    at systems.danger.kotlin.models.bitbucket.BitBucketServer$$serializer.deserialize(BitBucketServer.kt:13)
    at systems.danger.kotlin.models.bitbucket.BitBucketServer$$serializer.deserialize(BitBucketServer.kt:13)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:63)
    at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:32)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeNullableSerializableElement(AbstractDecoder.kt:79)
    at systems.danger.kotlin.models.danger.DangerDSL$$serializer.deserialize(DangerDSL.kt:14)
    at systems.danger.kotlin.models.danger.DangerDSL$$serializer.deserialize(DangerDSL.kt:14)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:63)
    at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:32)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
    at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
    at systems.danger.kotlin.models.danger.DSL$$serializer.deserialize(DangerDSL.kt:9)
    at systems.danger.kotlin.models.danger.DSL$$serializer.deserialize(DangerDSL.kt:9)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:63)
    at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:32)
    at kotlinx.serialization.json.Json.decodeFromString(Json.kt:95)
    at systems.danger.kotlin.MainDangerRunner.<init>(MainDangerRunner.kt:131)
    at systems.danger.kotlin.MainScriptKt.Danger(MainScript.kt:49)
    at Dangerfile_df.<init>(Dangerfile.df.kts:6)

I saw same issue with gitlab https://github.com/danger/kotlin/issues/145, I guess it's related to default argument. Can it be fixed?

gianluz commented 2 years ago

please see https://github.com/danger/kotlin/pull/211, should fix the issue

astoriawinter commented 2 years ago

@gianluz Hi, also faced same error with emailAddress in BitBucketServerUser. Email can be null, as user that created PR could be deleted. Please, add fix to this case as well.

msarelo commented 1 year ago

@gianluz Possibly a lot of data in BitBucket server responses could be nullable. I got two different errors:

  1. emailAddress in my cases when Bitbucket added some automatic comment.
  2. field tasks in BitBucketServerCommentDetail in my case is also nullable and got this error:
    kotlinx.serialization.MissingFieldException: Field 'tasks' is required for type with serial name 'systems.danger.kotlin.models.bitbucket.BitBucketServerCommentDetail', but it was missing