Skip to content

Conversation

tcheeric
Copy link
Owner

Summary

  • Defensively copy tag lists in GenericEvent constructors and setTags
  • Expose tags through an unmodifiable view
  • Update zap request validation tests to operate on tag copies

Testing

  • mvn -q verify (fails: Coverage checks have not been met for nostr-java-encryption)
  • mvn -q -pl nostr-java-event -am test

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

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 protects the GenericEvent class from external mutation by implementing defensive copying and immutable views of tag collections. The changes prevent external code from directly modifying an event's tags after creation or retrieval.

  • Implements defensive copying in constructors and setter methods to prevent shared mutable state
  • Exposes tags through an unmodifiable view to prevent external modification
  • Updates test cases to work with the new immutable tag access pattern

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
GenericEvent.java Adds defensive copying in constructor and setTags method, implements unmodifiable tag getter
ZapRequestEventValidateTest.java Updates tests to create tag copies before modification since direct tag mutation is no longer possible

tag.setParent(this);
}
}

public List<BaseTag> getTags() {
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

Adding a new public getTags() method could be a breaking change if this method already exists in the class or its parent classes. Verify that this doesn't override an existing method with different behavior.

Suggested change
public List<BaseTag> getTags() {
public List<BaseTag> getBaseTags() {

Copilot uses AI. Check for mistakes.

@tcheeric tcheeric merged commit 0895c09 into develop Aug 10, 2025
1 check failed
@tcheeric tcheeric deleted the codex/update-genericevent-tag-handling-methods branch August 10, 2025 20:34
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