Skip to content

fix(cache): improve TTLCache key validation#4900

Merged
JhaSourav07 merged 13 commits into
JhaSourav07:mainfrom
poonam072:fix/ttlcache-null-validation
Jun 14, 2026
Merged

fix(cache): improve TTLCache key validation#4900
JhaSourav07 merged 13 commits into
JhaSourav07:mainfrom
poonam072:fix/ttlcache-null-validation

Conversation

@poonam072

Copy link
Copy Markdown
Contributor

Description

Fixes #1875
Fix TTLCache key validation edge cases and align error handling with test expectations.

This ensures empty and whitespace-only keys are properly rejected and all unit tests pass consistently.

Pillar

  • 🛠️ Other (Bug fix, refactoring, tests)

Changes Made

  • Standardized assertValidKey logic for cache keys
  • Ensured empty string and whitespace keys are rejected consistently
  • Fixed mismatch between validation logic and test expectations
  • Ensured TTLCache methods (set, has, etc.) use unified validation

Testing

  • npm run lint (clean except minor warnings)
  • npm run build (successful)
  • npm run test (all tests passing)

Checklist before requesting review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally.
  • I have run npm run lint and fixed issues where possible.
  • I have run npm run test and all tests pass.
  • My changes do not break existing behavior.

@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@poonam072 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jun 8, 2026
@github-actions github-actions Bot added the type:bug Something isn't working as expected label Jun 8, 2026
@Aamod-Dev Aamod-Dev added level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. GSSoC 2026 mentor:Aamod007 labels Jun 11, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Excellent fix! Improving the TTLCache key validation prevents subtle caching bugs and null-key collisions. Approving!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for putting this together. The code looks clean and solves the issue effectively.

I'm happy to approve this. Great job!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution. I went through the changes and the overall approach looks good, but there are a few issues that should be addressed before this can be merged. Most of the concerns are related to correctness and maintainability.

  • There are merge conflicts with the base branch. Please resolve them to ensure existing functionality isn't broken.

Once these issues are addressed, I'll be happy to take another look. Thanks again for the contribution.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the updates! It looks like the CI pipeline (\Format · Lint · Typecheck · Test\ and \Production Build) is currently failing. Please run the build and tests locally to fix the issues so we can merge this. Thanks!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution. The overall approach looks good, but the CI pipeline is currently failing. Please run the checks (like npm run format, npm run lint, and npm run test) locally to identify and fix the issues. Let me know once it's green!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR is currently marked with the \status:blocked\ label. Please resolve the blockers so we can proceed with a full review and approval.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR is currently marked with the \status:blocked\ label. Please resolve the blockers so we can proceed with a full review and approval.

@Aamod-Dev Aamod-Dev added level:advanced Complex contributions involving architecture, optimization, or significant feature work quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. and removed level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. labels Jun 13, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution! I went through the changes and have evaluated them according to the rubric.

@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Jun 13, 2026
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3405.30 KB 3405.30 KB 0 B
Total CSS 252.94 KB 252.94 KB 0 B

@poonam072

poonam072 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Hi! The Vercel preview deployment is showing "Authorization required to deploy" since I'm an external contributor. Also, the branch shows gssoc:needs-rebase. Could a maintainer please guide or rebase/approve when possible? Thanks!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Crucial fix! I went through the changes and strictly validating TTL cache keys prevents accidental cache collisions and corrupted states.
Labels applied:

  • level:advanced: Enhancing cache integrity.
  • quality:clean: Safe validations.
  • ype:bug: Fixes cache pollution.

@Aamod-Dev Aamod-Dev added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 14, 2026
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 14, 2026
@JhaSourav07 JhaSourav07 merged commit 47bf434 into JhaSourav07:main Jun 14, 2026
6 of 7 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @poonam072! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@poonam072 poonam072 deleted the fix/ttlcache-null-validation branch June 14, 2026 12:14
@JhaSourav07 JhaSourav07 added gssoc:approved PR has been reviewed and accepted for valid contribution points and removed gssoc:approved PR has been reviewed and accepted for valid contribution points labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points gssoc:needs-rebase GSSoC 2026 level:advanced Complex contributions involving architecture, optimization, or significant feature work mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: TTLCache allows null or undefined keys without validation

3 participants