refactor(scripts): extract sanitizePromptInput into a shared module#9665
Open
zied-jlassi wants to merge 1 commit into
Open
refactor(scripts): extract sanitizePromptInput into a shared module#9665zied-jlassi wants to merge 1 commit into
zied-jlassi wants to merge 1 commit into
Conversation
The prompt-input sanitizer was duplicated in bedrock_classifier.ts and detect_duplicates.ts; the two copies had already drifted by a stray comment. Move it into a single sanitize_utils.ts and import it from both call sites so there is one implementation to maintain and review. No behaviour change: the extracted function body is identical to the previous copies (verified by `npm run build` and the existing jest suite).
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.
What
sanitizePromptInputwas duplicated verbatim inscripts/bedrock_classifier.tsandscripts/detect_duplicates.ts. The two copies had already drifted (one carried an extra comment line), which is how duplicated logic tends to start diverging over time.This moves the function into a single
scripts/sanitize_utils.tsand imports it from both call sites, following the existing*_utils.tsconvention already used byretry_utils.tsandrate_limit_utils.ts.Why
One implementation to maintain and review, instead of two near-identical copies that can silently diverge.
Behaviour
No behaviour change — the extracted function body is identical to the previous copies.
npm run build(tsc): passesdata_models.test.ts): 13/13 passNotes
MAX_TITLE_LENGTH/MAX_BODY_LENGTHconstants are intentionally left out of this PR to keep it focused on a single change.