Skip to content

:fix: add try-catch for JSON.parse of emailProofInfo URL param#286

Merged
wryonik merged 1 commit into
mainfrom
shubham/reg-628-broken-shared-proof-link-on-second-share
Jan 15, 2026
Merged

:fix: add try-catch for JSON.parse of emailProofInfo URL param#286
wryonik merged 1 commit into
mainfrom
shubham/reg-628-broken-shared-proof-link-on-second-share

Conversation

@wryonik

@wryonik wryonik commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Type of Change

  • Bug fix (hotfix)
  • New feature
  • Refactor
  • Documentation
  • Other (please describe)

Target Branch

  • dev - New feature or non-urgent fix
  • staging - Ready for QA validation
  • main - Hotfix for production issue

Changes Made

Breaking Changes

Testing

  • Tested locally
  • Added/updated tests
  • Verified in development environment

Checklist

  • Code follows the project's style guidelines
  • Self-review completed
  • Comments added for complex code sections
  • Documentation updated if needed
  • No new warnings generated

Screenshots/Recordings

Related Issues

Fixes #282

Additional Notes

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced proof data loading with improved error handling to prevent runtime crashes and ensure consistent fallback behavior when invalid data is encountered.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 5, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The emailProof derivation logic was refactored to always invoke the store hook unconditionally, eliminating conditional hook usage. A defensive IIFE now wraps local JSON parsing with try/catch error handling, falling back to the stored proof on parse failure or when local data is absent, improving React hook compliance and reliability.

Changes

Cohort / File(s) Summary
Hook Invocation & Error Handling Refactor
src/app/[id]/proofs/[proofId]/page.tsx
Restructured emailProof derivation to unconditionally call storeProof hook. Replaced conditional hook logic with defensive IIFE containing try/catch for local URL-provided JSON parsing. Added fallback mechanism for malformed JSON to prevent runtime crashes while maintaining deterministic behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Poem

A hook once danced alone, now stands so tall,
With try/catch armor, catching every fall.
From store to JSON, with fallbacks so keen—
The sturdiest proof we've ever seen! 🐰

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a try-catch for JSON.parse of the emailProofInfo URL parameter to handle parsing errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63c8afa and ef5b2e6.

📒 Files selected for processing (1)
  • src/app/[id]/proofs/[proofId]/page.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
src/app/[id]/proofs/[proofId]/page.tsx (1)
src/lib/stores/useProofEmailStore.ts (1)
  • useProofEmailStore (37-153)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (1)
src/app/[id]/proofs/[proofId]/page.tsx (1)

33-45: LGTM! Proper defensive handling for URL parameter parsing.

The try-catch correctly guards against malformed JSON in the emailProofInfo URL parameter, and the fallback to storeProof is appropriate. The unconditional hook call on line 33 also fixes the React rules-of-hooks compliance issue mentioned in the summary.

Optional consideration for future hardening: The parsed JSON is used as-is without shape validation. If a user crafts a URL with valid JSON but an unexpected structure, downstream code (e.g., new Proof(blueprint, emailProof) on line 155) could fail. Consider adding runtime validation (e.g., with Zod or a type guard) in a follow-up if URL tampering is a concern.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wryonik wryonik requested review from BornPsych and rutefig January 5, 2026 07:05
@zkemailverify zkemailverify temporarily deployed to shubham/reg-628-broken-shared-proof-link-on-second-share - registry PR #286 January 15, 2026 00:17 — with Render Destroyed
@wryonik wryonik merged commit 4a07f20 into main Jan 15, 2026
2 of 3 checks passed
@wryonik wryonik deleted the shubham/reg-628-broken-shared-proof-link-on-second-share branch January 15, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken shared proof link on second share

3 participants