feat(shared-contact-notes): input safety and perf guards#1220
Open
michaelvic123 wants to merge 2 commits into
Open
feat(shared-contact-notes): input safety and perf guards#1220michaelvic123 wants to merge 2 commits into
michaelvic123 wants to merge 2 commits into
Conversation
Safety: - Added LIMITS constant (CONTENT_MAX: 10_000, ID_MAX: 256) to types.ts - validateCreateNote/validateUpdateNote now reject oversized content - New validateId() helper rejects empty or oversized ID strings - service.ts uses validateId() consistently across all ID-bearing methods Performance: - Added maxNotesPerContact to ServiceConfig (default 500) - getByContact breaks early once the cap is reached, avoiding full map iteration on contacts with large note histories Tests: - Length limit rejection for content, contactId, authorId, update content - validateId edge cases (empty, oversized, custom field name) - maxNotesPerContact cap behaviour with 20-note fixture
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.
closes #657
What
Adds safety and performance constraints to the
shared-contact-notesV2 tool before any future integration. All changes stay insidetools/v2/team/shared-contact-notes/.Changes
types.tsLIMITSconstant —CONTENT_MAX: 10_000,ID_MAX: 256. Centralises the hard limits so validators and tests stay in sync.maxNotesPerContacttoServiceConfig— performance cap forgetByContact.validation.tsvalidateCreateNote/validateUpdateNotenow reject inputs exceedingLIMITS.validateId()helper — rejects empty or oversized ID strings. Replaces inline guard duplication across service methods.service.tsupdate,delete,archive,getByContact) usevalidateId()consistently.getByContactbreaks early whenmaxNotesPerContactis reached — avoids iterating the full map on contacts with large note histories. Default cap is 500.tests/service.test.tscontent,contactId,authorId, and update content.validateIdedge cases.maxNotesPerContactcap verified against a 20-note fixture.Checks