Skip to content

Comments

[LFXV2-1114] Add UnmarshalJSON methods to support flexible type casting#43

Merged
andrest50 merged 2 commits intomainfrom
andrest50/unmarshal-json
Feb 20, 2026
Merged

[LFXV2-1114] Add UnmarshalJSON methods to support flexible type casting#43
andrest50 merged 2 commits intomainfrom
andrest50/unmarshal-json

Conversation

@andrest50
Copy link
Contributor

@andrest50 andrest50 commented Feb 19, 2026

Summary

  • Add custom UnmarshalJSON methods to handle flexible type casting for numeric fields
  • Support both string and integer inputs for fields like Duration, Type, RepeatInterval, etc.
  • Maintain existing MarshalJSON methods to ensure proper output formatting

Changes

  • Added UnmarshalJSON to ZoomMeetingRecurrence struct to handle string/int conversion for 6 numeric fields
  • Added UnmarshalJSON to UpdatedOccurrence struct for Duration field
  • Added UnmarshalJSON to meetingInput struct for 7 numeric fields (Duration, EarlyJoinTimeMinutes, LastEndTime, and job count fields)
  • Added UnmarshalJSON methods to survey and voting model structs for similar flexible type handling
  • Cleaned up handlers to remove commented-out code

Ticket

LFXV2-1114

🤖 Generated with Claude Code

Signed-off-by: Andres Tobon andrest2455@gmail.com

Copilot AI review requested due to automatic review settings February 19, 2026 23:51
@andrest50 andrest50 requested review from a team and emsearcy as code owners February 19, 2026 23:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 string to int type in survey, voting, and meeting model structs
  • Added UnmarshalJSON methods 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 UnmarshalJSON methods
  • Updated .gitignore to 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.

@andrest50 andrest50 force-pushed the andrest50/unmarshal-json branch from ce16191 to a5eb859 Compare February 20, 2026 00:07
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>
@andrest50 andrest50 force-pushed the andrest50/unmarshal-json branch from a5eb859 to ae2bfb8 Compare February 20, 2026 00:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// Convert recording_count from string to int

Copilot uses AI. Check for mistakes.
@andrest50 andrest50 merged commit 0e89b60 into main Feb 20, 2026
7 of 8 checks passed
@andrest50 andrest50 deleted the andrest50/unmarshal-json branch February 20, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants