question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ashishdhingracommented, Dec 2, 2020

Hi @ingun37,

The SDK Model class ArtifactLocationType is auto-generated. Hence, I do not see it to be fixed in near future. Basically its the problem with the CodePipeline returning string but model class expecting it of a certain type. Hence the problem with the serialization process from JSON. Unfortunately, these types of constant classes cannot be represented in JSON. The workaround as mentioned earlier, is to write custom class (which you implemented) and/or write custom JsonConverter.

Thanks, Ashish

0reactions
github-actions[bot]commented, Dec 2, 2020

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Edit a pipeline in CodePipeline - AWS Documentation
A pipeline describes the release process that you want AWS CodePipeline to follow, including stages and actions that must be completed. You can...
Read more >
CodePipeline pipeline structure reference
Describes the pipeline structure.
Read more >
Create a pipeline in CodePipeline - AWS Documentation
Describes how to create a pipeline, which is an automated workflow of continuous integration and release events, in CodePipeline by using the console...
Read more >
Create and add a custom action in CodePipeline
Describes how to create a custom action for use in a pipeline or all of your pipelines by using the console or the...
Read more >
Troubleshooting CodePipeline - AWS Documentation
Problem: The download of an artifact stored in an Amazon S3 bucket will fail if the pipeline and bucket are created in different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found