Skip to content

The JSON value could not be converted to Amazon.CodePipeline.ArtifactLocationType #768

@ingun37

Description

@ingun37

Description

DefaultLambdaJsonSerializer fails to decode payload coming from CodePipeline, specifically
$['CodePipeline.job'].data.inputArtifacts[0].location.type
to
Amazon.CodePipeline.ArtifactLocationType

Reproduction Steps

Define Lambda handler with type of Codepipeline payload

    public class CodePipelineEvent
    {
        [JsonPropertyName("CodePipeline.job")]
        public Amazon.CodePipeline.Model.Job job { get; set; }
    }
    public Task FunctionHandler(CodePipelineInput input, ILambdaContext context) { ... }

then test with an actual payload.

Logs

Error converting the Lambda event JSON payload to type BenchmarkingLoader.CodePipelineInput: The JSON value could not be converted to Amazon.CodePipeline.ArtifactLocationType. Path: $['CodePipeline.job'].data.inputArtifacts[0].location.type | LineNumber: 0 | BytePositionInLine: 258.: JsonSerializerException
   at Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer.Deserialize[T](Stream requestStream)
   at lambda_method(Closure , Stream , Stream , LambdaContextInternal )

   at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
   at System.Text.Json.JsonPropertyInfoNotNullable`4.OnRead(ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.JsonPropertyInfo.Read(JsonTokenType tokenType, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
   at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader)
   at System.Text.Json.JsonSerializer.ParseCore(ReadOnlySpan`1 utf8Json, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](ReadOnlySpan`1 utf8Json, JsonSerializerOptions options)
   at Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer.Deserialize[T](Stream requestStream)

Environment

    <PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
    <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.0.1" />
    <PackageReference Include="AWSSDK.CodePipeline" Version="3.5.1.5" />
    <PackageReference Include="AWSSDK.S3" Version="3.5.5.2" />

Lambda

Resolution


This is a 🐛 bug-report

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions