The JSON value could not be converted to Amazon.CodePipeline.ArtifactLocationType
See original GitHub issueDescription
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:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top 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 >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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 customJsonConverter
.Thanks, Ashish
⚠️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.