Skip to content

Add JSON validation for channel and merchant events #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2025

Conversation

tcheeric
Copy link
Owner

Summary

  • validate JSON contents for ChannelCreateEvent and ChannelMetadataEvent
  • validate MerchantEvent content and check required fields for product and stall events
  • add unit tests covering invalid or incomplete JSON

Testing

  • mvn -q verify
  • mvn -DskipTests install

https://chatgpt.com/codex/tasks/task_b_688a8503ca2c83319e47e1b7c88d7c8e

Copy link
Contributor

@Copilot 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 PR adds JSON validation for channel and merchant events to ensure data integrity and proper field requirements. The validation covers both JSON parsing and required field checks for different event types.

  • Implements content validation for channel events (ChannelCreateEvent and ChannelMetadataEvent) with required field checks
  • Adds validation for merchant events (CreateOrUpdateProductEvent and CreateOrUpdateStallEvent) with specific field requirements
  • Includes comprehensive unit tests for invalid JSON and missing required fields scenarios

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
JsonContentValidationTest.java New test file covering validation scenarios for invalid JSON and missing required fields
MerchantEvent.java Adds base validation for merchant entities with ID field requirement
CreateOrUpdateStallEvent.java Implements stall-specific validation for name and currency fields
CreateOrUpdateProductEvent.java Implements product-specific validation for name, currency, and price fields
ChannelMetadataEvent.java Adds validation for channel profile with name, about, and picture field requirements
ChannelCreateEvent.java Implements identical validation to ChannelMetadataEvent for channel profile fields

if (profile.getPicture() == null) {
throw new AssertionError("Invalid `content`: `picture` field is required.");
}
} catch (Exception e) {
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

This catch block catches all exceptions including AssertionError, which masks validation errors. Consider catching only JSON parsing exceptions (e.g., JsonProcessingException) and allowing AssertionErrors to propagate naturally.

Suggested change
} catch (Exception e) {
} catch (JsonProcessingException e) {

Copilot uses AI. Check for mistakes.

throw new AssertionError("Invalid `content`: `picture` field is required.");
}

} catch (Exception e) {
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

This catch block catches all exceptions including AssertionError, which masks validation errors. Consider catching only JSON parsing exceptions (e.g., JsonProcessingException) and allowing AssertionErrors to propagate naturally.

Suggested change
} catch (Exception e) {
} catch (JsonProcessingException e) {

Copilot uses AI. Check for mistakes.

Comment on lines +59 to +60
} catch (AssertionError e) {
throw e;
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The try-catch block that re-throws AssertionError is redundant. AssertionErrors should be allowed to propagate naturally without explicit catching and re-throwing.

Suggested change
} catch (AssertionError e) {
throw e;

Copilot uses AI. Check for mistakes.

Comment on lines +55 to +56
} catch (AssertionError e) {
throw e;
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The try-catch block that re-throws AssertionError is redundant. AssertionErrors should be allowed to propagate naturally without explicit catching and re-throwing.

Suggested change
} catch (AssertionError e) {
throw e;

Copilot uses AI. Check for mistakes.

Comment on lines +52 to +53
} catch (AssertionError e) {
throw e;
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The try-catch block that re-throws AssertionError is redundant. AssertionErrors should be allowed to propagate naturally without explicit catching and re-throwing.

Suggested change
} catch (AssertionError e) {
throw e;

Copilot uses AI. Check for mistakes.

@tcheeric tcheeric merged commit 7b32747 into develop Jul 30, 2025
@tcheeric tcheeric deleted the codex/override-validatecontent-for-json-events branch July 30, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant