Commit f1cb454
fix(cli): activate contract migration in riverctl room operations (#193)
* fix(cli): activate contract migration in riverctl room operations
The ensure_room_migrated() function was fully implemented but never
called. When bundled WASM changed (e.g., after a release), riverctl
would try to GET/UPDATE the new contract key which had no state yet,
causing timeouts.
Two bugs fixed:
1. Wire ensure_room_migrated() into get_room() and subscribe_and_stream()
so migration runs automatically before any room operation.
2. Fix the migration-needed check: load_rooms() already regenerates the
stored key to match current WASM, so comparing stored vs expected was
always equal. Now checks previous_contract_key instead.
Closes #192
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(cli): simplify migration log and test assertions
- Replace unwrap_or("unknown") with unwrap() since we already early-return
when previous_contract_key_str is None
- Simplify test assertions using as_deref() pattern
- Remove unnecessary mut binding in test
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(cli): remove double migration call in subscribe_and_stream
subscribe_and_stream called ensure_room_migrated then get_room which
also calls ensure_room_migrated. Removed the explicit call since
get_room handles migration internally. Also added assertion that
previous_contract_key is None for rooms with current WASM.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(cli): address review findings from skeptical reviewer
1. Clear previous_contract_key after ALL successful migration paths
(timeout and catch-all), not just the "already exists" path.
Prevents redundant migration re-attempts on subsequent calls.
2. Restore "Room not found" guard in subscribe_and_stream that was
lost when refactoring to use get_room for migration.
3. Fix misleading test comment about load_rooms behavior during
add_room (file doesn't exist yet, so no regeneration occurs).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent a462ff2 commit f1cb454
3 files changed
+88
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
357 | 360 | | |
358 | 361 | | |
359 | 362 | | |
| |||
865 | 868 | | |
866 | 869 | | |
867 | 870 | | |
868 | | - | |
869 | 871 | | |
870 | 872 | | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
875 | 878 | | |
876 | 879 | | |
877 | 880 | | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
878 | 884 | | |
879 | 885 | | |
880 | | - | |
881 | | - | |
| 886 | + | |
| 887 | + | |
882 | 888 | | |
883 | 889 | | |
884 | 890 | | |
| |||
925 | 931 | | |
926 | 932 | | |
927 | 933 | | |
| 934 | + | |
928 | 935 | | |
929 | 936 | | |
930 | 937 | | |
| |||
935 | 942 | | |
936 | 943 | | |
937 | 944 | | |
938 | | - | |
939 | 945 | | |
940 | 946 | | |
941 | 947 | | |
| |||
961 | 967 | | |
962 | 968 | | |
963 | 969 | | |
| 970 | + | |
964 | 971 | | |
965 | 972 | | |
966 | 973 | | |
| |||
1778 | 1785 | | |
1779 | 1786 | | |
1780 | 1787 | | |
1781 | | - | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
1782 | 1791 | | |
1783 | 1792 | | |
1784 | 1793 | | |
| |||
2408 | 2417 | | |
2409 | 2418 | | |
2410 | 2419 | | |
2411 | | - | |
2412 | | - | |
| 2420 | + | |
| 2421 | + | |
2413 | 2422 | | |
2414 | 2423 | | |
2415 | 2424 | | |
2416 | | - | |
2417 | | - | |
2418 | | - | |
2419 | | - | |
2420 | | - | |
2421 | 2425 | | |
2422 | 2426 | | |
2423 | 2427 | | |
| |||
2431 | 2435 | | |
2432 | 2436 | | |
2433 | 2437 | | |
2434 | | - | |
2435 | | - | |
2436 | | - | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
2437 | 2442 | | |
2438 | 2443 | | |
2439 | 2444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
350 | 402 | | |
351 | 403 | | |
352 | 404 | | |
| |||
371 | 423 | | |
372 | 424 | | |
373 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
374 | 436 | | |
375 | 437 | | |
0 commit comments