Commit 9cf6cb7
committed
fix: add skipOnUnsynced option to reconcileOrganization to prevent data loss
Bugbot flagged a High Severity regression on 6d41b71: reconcileOrganization
now silently returns (no throw) when a store is unsynced or the subscribe
call fails, but the user-facing resyncOrganization controller
(POST /organizations/resync and POST /v2/organizations/resync) calls
reconcileOrganization and then unconditionally:
1. Resets registryHash / registry_hash to '0'
2. Destroys ModelKeys rows (V1) / AuditV2 rows (V2) for the orgUid
Before this PR, reconcileOrganization would either complete or throw; the
throw would hit the controller's catch, roll back the transaction, and
return 400 without destroying data. After 6d41b71, a transient datalayer
hiccup (subscribe returns false, sync-status RPC fails, etc.) causes the
resync endpoint to "succeed" with silent data deletion.
Fix: add a { skipOnUnsynced } option to both V1 and V2
reconcileOrganization.
- Default (false): throw on any subscribe-failed / store-unsynced /
status-check-failed condition. Restores pre-6e76235 behavior for
request-path callers.
- true: silent skip with an INFO log. Preserves the sync-blocking
regression fix for background task callers
(validate-organization-table-and-subscriptions*.js).
Background task callers updated to pass { skipOnUnsynced: true }. The
two resync controllers are unchanged — they continue to call
reconcileOrganization with the (now throwing) default behavior, which
hits their existing catch block and rolls back the transaction.
Adds six contract tests covering the new option in simulator mode
(signature acceptance, no-option back-compat, no signature errors for
either value). Production throw/skip behavior remains covered by live
integration tests; simulator mode cannot reach the pre-check block
(wrapped in !USE_SIMULATOR for V2, guarded at the top of the function
for V1).1 parent 6d41b71 commit 9cf6cb7
5 files changed
Lines changed: 220 additions & 57 deletions
File tree
- src
- models
- organizations
- v2
- tasks
- tests/v2/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
789 | 789 | | |
790 | 790 | | |
791 | 791 | | |
792 | | - | |
| 792 | + | |
793 | 793 | | |
794 | 794 | | |
795 | 795 | | |
| |||
830 | 830 | | |
831 | 831 | | |
832 | 832 | | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
833 | 846 | | |
834 | 847 | | |
835 | 848 | | |
| |||
840 | 853 | | |
841 | 854 | | |
842 | 855 | | |
| 856 | + | |
843 | 857 | | |
844 | 858 | | |
845 | 859 | | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
| 860 | + | |
850 | 861 | | |
851 | 862 | | |
852 | | - | |
853 | | - | |
854 | | - | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
855 | 867 | | |
856 | 868 | | |
857 | 869 | | |
| 870 | + | |
858 | 871 | | |
859 | 872 | | |
860 | 873 | | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
| 874 | + | |
865 | 875 | | |
866 | 876 | | |
867 | | - | |
868 | | - | |
869 | | - | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
870 | 881 | | |
871 | 882 | | |
872 | 883 | | |
873 | 884 | | |
874 | 885 | | |
875 | 886 | | |
| 887 | + | |
876 | 888 | | |
877 | 889 | | |
878 | 890 | | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
| 891 | + | |
883 | 892 | | |
884 | 893 | | |
885 | | - | |
886 | | - | |
887 | | - | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
888 | 898 | | |
889 | 899 | | |
890 | 900 | | |
| |||
1014 | 1024 | | |
1015 | 1025 | | |
1016 | 1026 | | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1020 | 1030 | | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1027 | 1041 | | |
1028 | 1042 | | |
1029 | 1043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1835 | 1835 | | |
1836 | 1836 | | |
1837 | 1837 | | |
1838 | | - | |
| 1838 | + | |
| 1839 | + | |
1839 | 1840 | | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
1840 | 1851 | | |
| 1852 | + | |
| 1853 | + | |
1841 | 1854 | | |
1842 | | - | |
| 1855 | + | |
1843 | 1856 | | |
1844 | 1857 | | |
1845 | 1858 | | |
| |||
1855 | 1868 | | |
1856 | 1869 | | |
1857 | 1870 | | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1858 | 1882 | | |
1859 | 1883 | | |
1860 | 1884 | | |
| |||
1864 | 1888 | | |
1865 | 1889 | | |
1866 | 1890 | | |
| 1891 | + | |
1867 | 1892 | | |
1868 | 1893 | | |
1869 | 1894 | | |
1870 | | - | |
1871 | | - | |
1872 | | - | |
1873 | | - | |
| 1895 | + | |
1874 | 1896 | | |
1875 | 1897 | | |
1876 | | - | |
1877 | | - | |
1878 | | - | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
1879 | 1902 | | |
1880 | 1903 | | |
1881 | 1904 | | |
| 1905 | + | |
1882 | 1906 | | |
1883 | 1907 | | |
1884 | 1908 | | |
1885 | | - | |
1886 | | - | |
1887 | | - | |
1888 | | - | |
| 1909 | + | |
1889 | 1910 | | |
1890 | 1911 | | |
1891 | | - | |
1892 | | - | |
1893 | | - | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
1894 | 1916 | | |
1895 | 1917 | | |
1896 | 1918 | | |
1897 | 1919 | | |
| 1920 | + | |
1898 | 1921 | | |
1899 | 1922 | | |
1900 | 1923 | | |
1901 | | - | |
1902 | | - | |
1903 | | - | |
1904 | | - | |
| 1924 | + | |
1905 | 1925 | | |
1906 | 1926 | | |
1907 | | - | |
1908 | | - | |
1909 | | - | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
1910 | 1931 | | |
1911 | 1932 | | |
1912 | 1933 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
0 commit comments