fix(events): correct CodePipelineEventBridge version field types (fixes #552)#626
Open
fix(events): correct CodePipelineEventBridge version field types (fixes #552)#626
Conversation
added 2 commits
May 9, 2026 07:41
The AWS service team confirmed the correct types for version fields in CodePipelineCloudWatchEvent (issue aws#552): - .version (top level): string -- already correct - .detail.version: numeric -- was int64, now json.Number - .detail.type.version: string -- was int64, now string The previous int64 types caused UnmarshalTypeError at runtime when AWS sent detail.version as a float (e.g. 2.0) or detail.type.version as a quoted string (e.g. "1"). json.Number is used for detail.version to handle both integer and float representations without losing the raw value. Test fixture updated to reflect real AWS payload format, and a new fixture added to cover the float version regression case. Fixes aws#552
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #626 +/- ##
=======================================
Coverage 75.12% 75.12%
=======================================
Files 36 36
Lines 1419 1419
=======================================
Hits 1066 1066
Misses 274 274
Partials 79 79 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #552 —
UnmarshalTypeErrorwhen handlingCodePipelineEventBridgeEvent.The AWS service team confirmed in the issue the correct types for version fields:
.version(top-level)stringstring.detail.versionint64json.Number1or2.0(float).detail.type.versionint64string"1"Why
json.Numberfordetail.version?AWS sends this field as either an integer (
1) or a float (2.0) depending on the pipeline version. Usingjson.Numberpreserves the raw value and avoidsUnmarshalTypeErrorfor both representations. Callers can use.Int64()or.Float64()to convert as needed.Breaking change note
This changes public struct field types. Users directly comparing or assigning
detail.Versionasint64will need to update their code. However, the previous types caused a hard unmarshal failure at runtime — so the existing types were already broken for real AWS payloads.Changes
events/codepipeline_cloudwatch.go: FixCodePipelineEventDetail.Version(int64→json.Number) andCodePipelineEventDetailType.Version(int64→string)events/codepipeline_cloudwatch_test.go: Update expected values; add regression test case for float version payloadevents/testdata/codepipeline-action-execution-stage-change-event.json: Updatetype.versionfrom1to"1"to match real AWS formatevents/testdata/codepipeline-action-execution-stage-change-event-float-version.json: New fixture withdetail.version: 2.0to cover the float regression caseTest plan
go test ./events/ -run TestUnmarshalCodePipelineEventpasses (4 cases including new float regression)go test ./events/(full events package) passes with no regressions