Commit 0c40fdd
Fix cookie JSON parsing by disabling automatic parsing (ENG-6818) (#5616)
* Fix cookie JSON parsing by disabling automatic parsing
- Add true parameter to cookies.get() calls in state.js to prevent
universal-cookies from automatically parsing JSON strings
- Add comprehensive integration tests for JSON cookie values including:
- Dictionary objects serialized as JSON
- Arrays serialized as JSON
- Complex nested objects
- JSON with special characters and escaping
- Empty JSON objects and arrays
Fixes ENG-6818: Cookie handling bug where JSON-formatted values
were being parsed into dictionaries instead of preserved as strings
Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
* Fix pre-commit formatting issues in JSON cookie tests
- Wrap long JSON string with escapes to meet line length requirements
- Use consistent double quotes for empty JSON strings
- Apply formatting changes as required by pre-commit hooks
Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
* Update reflex/.templates/web/utils/state.js
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
* Remove unused token variable from JSON cookie test
- Fix pre-commit ruff check failure F841 (unused variable)
- The test doesn't require authentication to verify JSON string preservation
Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
* Fix timing issue in JSON cookie test by adding poll_for_token call
- Add back poll_for_token() call before accessing DOM elements
- Follows the same pattern as the existing working test
- Ensures app is fully loaded before test execution
Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
* Update test_client_storage.py
* Add browser refresh to JSON cookie test to trigger hydration bug
- Refresh browser after setting each JSON cookie value
- Re-acquire DOM elements after refresh to test cookie hydration
- Ensures test properly exercises the universal-cookies JSON parsing bug
- Addresses feedback from masenf to test the actual bug scenario
Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
* Fix pre-commit formatting issues in JSON cookie test
- Remove trailing whitespace from empty lines
- Address ruff formatting requirements for browser refresh test enhancement
Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
* Refactor JSON cookie test to eliminate code duplication
- Create helper function test_json_cookie_with_refresh() as requested by masenf
- Encapsulates full test cycle: poll token, get element, set value, assert, refresh, poll token, assert
- Reduces test from ~60 lines of duplicated logic to ~20 lines using helper function
- Maintains identical functionality and test coverage
- Addresses GitHub comment feedback for cleaner code organization
Co-Authored-By: masen@reflex.dev <masen@reflex.dev>
* Fix it properly Anna Maria, with breadcrumbs
* Yeeeah, I want it that way 🕺
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: masen@reflex.dev <masen@reflex.dev>
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>1 parent 7e0a95f commit 0c40fdd
2 files changed
Lines changed: 74 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
794 | | - | |
| 794 | + | |
795 | 795 | | |
796 | | - | |
| 796 | + | |
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
0 commit comments