UnmarshalTypeError on CodePipelineEventBridgeEvent

Open
#552 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
aws, go
Domain
cloud

Research direction

Start by inspecting the events.CodePipelineEventBridgeEvent entry point and the CodePipelineEventDetail fields named in the errors. Compare those fields with the EventBridge payload examples in the issue, especially detail.version and detail.type.version. Done means the reported CodePipeline event variants unmarshal without errors using types that match the incoming values.

Written by the indexing model from the issue text.

Description

bug type/events

Is your feature request related to a problem? Please describe.

Triggering a lambda with EventBridge CodePipeline events, i.e.:

{
  "detail-type": [
    "CodePipeline Pipeline Execution State Change",
    "CodePipeline Stage Execution State Change",
    "CodePipeline Action Execution State Change"
  ],
  "source": [
    "aws.codepipeline"
  ]
}

The Lambda in question has this structure:

func handler(_ context.Context, event *events.CodePipelineEventBridgeEvent) error {}

Upon execution, it almost immediately fails and outputs one of two errors (so far):

json: cannot unmarshal number 2.0 into Go struct field CodePipelineEventDetail.detail.version of type int64
json: cannot unmarshal string into Go struct field CodePipelineEventDetailType.detail.type.version of type int64

Describe the solution you'd like

I'm fairly certain I'm using the correct event type here, but I could be wrong. However, I'd like a solution to the lambda not failing immediately and the type being correct for what EventBridge is passing into the lambda.

Dominant language
Go
Stars
3.8k
Forks
578
Avg merge
16h 56m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/aws-lambda-go

All issues in aws/aws-lambda-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.