[LFXV2-1114] Add UnmarshalJSON methods to support flexible type casting#43
[LFXV2-1114] Add UnmarshalJSON methods to support flexible type casting#43
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request aims to add custom UnmarshalJSON methods to handle flexible type casting between string and integer types for numeric fields across survey, voting, and meeting data models. The changes are intended to support data coming from both Meltano (which provides strings) and DynamoDB (which provides integers).
Changes:
- Changed multiple numeric fields from
stringtointtype in survey, voting, and meeting model structs - Added
UnmarshalJSONmethods to 7 structs to handle flexible string/int conversion for numeric fields - Removed manual string-to-int conversion logic from handler functions, relying on the new
UnmarshalJSONmethods - Updated
.gitignoreto use.env*pattern instead of.env
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| .gitignore | Updated to match all .env* files instead of just .env |
| cmd/lfx-v1-sync-helper/models_voting.go | Added UnmarshalJSON methods to PollDB and RankedChoiceAnswer structs; changed 4 fields from string to int |
| cmd/lfx-v1-sync-helper/models_surveys.go | Added UnmarshalJSON methods to SurveyDatabase, SurveyCommittee, and SurveyResponseDatabase structs; changed 12+ fields from string to int |
| cmd/lfx-v1-sync-helper/models_meetings.go | Added UnmarshalJSON methods to ZoomMeetingRecurrence, UpdatedOccurrence, and meetingInput structs for flexible numeric type handling |
| cmd/lfx-v1-sync-helper/handlers_voting.go | Removed manual string-to-int conversion logic, now handled by UnmarshalJSON |
| cmd/lfx-v1-sync-helper/handlers_survey.go | Removed manual string-to-int conversion logic, now handled by UnmarshalJSON |
| cmd/lfx-v1-sync-helper/handlers_meetings.go | Removed manual string-to-int conversion logic for meetings and related types |
Comments suppressed due to low confidence (3)
cmd/lfx-v1-sync-helper/handlers_meetings.go:1718
- The manual string-to-int conversion logic for RecordingCount, TotalSize, and nested session/file fields was removed, but no corresponding UnmarshalJSON method was added to the pastMeetingRecordingInput (or its nested types ZoomPastMeetingRecordingSession and ZoomPastMeetingRecordingFile) to handle flexible type casting. This will break deserialization when string values are provided for these numeric fields. Either restore the conversion logic here or add UnmarshalJSON methods to these structs.
}
cmd/lfx-v1-sync-helper/handlers_meetings.go:1718
- This comment is outdated - the conversion code it refers to has been removed. Since the conversion is supposedly handled by UnmarshalJSON methods, this comment should be removed. However, note that there are actually no UnmarshalJSON methods added for pastMeetingRecordingInput or its nested types, so the conversion logic may need to be restored.
}
cmd/lfx-v1-sync-helper/handlers_meetings.go:1414
- The manual string-to-int conversion logic for AverageAttendance was removed, but no corresponding UnmarshalJSON method was added to the pastMeetingAttendeeInput struct to handle flexible type casting. This will break deserialization when string values are provided for this numeric field. Either restore the conversion logic here or add an UnmarshalJSON method to pastMeetingAttendeeInput.
funcLogger.DebugContext(ctx, "processing zoom past meeting attendee update")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ce16191 to
a5eb859
Compare
Implemented custom UnmarshalJSON methods for database structs to handle both native types (from DynamoDB streams) and string types (from Meltano). This fixes issues where DynamoDB stream events were broken due to type mismatches. Changes: - Updated PollDB, RankedChoiceAnswer (voting models) to use int types - Updated SurveyDatabase, SurveyCommittee, SurveyResponseDatabase to use int types - Updated ZoomMeetingRecurrence, UpdatedOccurrence, meetingInput to handle int types - Added UnmarshalJSON methods that accept both string and int inputs - Simplified handlers to use direct field assignment instead of manual strconv - Removed ~150+ lines of redundant type conversion code The UnmarshalJSON methods follow a consistent pattern: - Accept string inputs and convert using strconv.Atoi/ParseInt - Accept int/int64 inputs directly - Return errors for invalid types - Maintain backward compatibility with Meltano string inputs Generated with Claude Code: https://claude.com/claude-code Signed-off-by: Andres Tobon <andrest2455@gmail.com>
a5eb859 to
ae2bfb8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1883,51 +1698,6 @@ func convertMapToInputPastMeetingRecording(v1Data map[string]any) (*pastMeetingR | |||
| } | |||
|
|
|||
| // Convert recording_count from string to int | |||
There was a problem hiding this comment.
This comment is outdated and misleading. The code that follows no longer converts recording_count from string to int. Since the RecordingCount field has json:"-" tag (excluded from JSON unmarshaling), this conversion was never needed. Remove this comment to avoid confusion.
| // Convert recording_count from string to int |
Summary
UnmarshalJSONmethods to handle flexible type casting for numeric fieldsDuration,Type,RepeatInterval, etc.MarshalJSONmethods to ensure proper output formattingChanges
UnmarshalJSONtoZoomMeetingRecurrencestruct to handle string/int conversion for 6 numeric fieldsUnmarshalJSONtoUpdatedOccurrencestruct for Duration fieldUnmarshalJSONtomeetingInputstruct for 7 numeric fields (Duration, EarlyJoinTimeMinutes, LastEndTime, and job count fields)UnmarshalJSONmethods to survey and voting model structs for similar flexible type handlingTicket
LFXV2-1114
🤖 Generated with Claude Code
Signed-off-by: Andres Tobon andrest2455@gmail.com